Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- SERVICES & MODULES
- local Players = game:GetService("Players")
- local CollectionService = game:GetService("CollectionService")
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local Remotes = require(ReplicatedStorage.Modules.Remotes)
- local GetFarm = require(ReplicatedStorage.Modules.GetFarm)
- local InventoryService = require(ReplicatedStorage.Modules.InventoryService)
- local sellRemote = ReplicatedStorage
- :WaitForChild("GameEvents")
- :WaitForChild("Sell_Inventory")
- local sell_One_Remote = ReplicatedStorage
- :WaitForChild("GameEvents")
- :WaitForChild("Sell_Item")
- local CalculatePetValue = require(ReplicatedStorage.Modules:WaitForChild("CalculatePetValue"))
- local CalculatePlantValue = require(ReplicatedStorage.Modules:WaitForChild("CalculatePlantValue"))
- local MutationHandler = require(ReplicatedStorage.Modules:WaitForChild("MutationHandler"))
- local ActivePetsService = require(ReplicatedStorage.Modules.PetServices.ActivePetsService)
- local PetConfig = require(ReplicatedStorage.Data.PetRegistry.PetConfig)
- -- PLAYER & FARM ROOT
- local player = Players.LocalPlayer
- local farmRoot = GetFarm(player)
- local HttpService = game:GetService("HttpService")
- local webhookUrl = "https://discord.com/api/webhooks/1371732167499186206/cAHDH567wnjAb7oncu7Hn5OsekL9GquwrFxarRJD-zz7jkFoM8y9qFslznQZhAX7HTT5" -- replace with your Discord webhook URL
- local hasSpecialPlant = false
- -- Add this variable near the other local variable declarations
- local noMorePlantsToDelete = false
- local isAutoToggleUIEnabled = false
- local autoToggleUIThread = nil
- local isAutoSellEnabled = false
- local autoSellThread = nil
- local isAutoSellOneByOneEnabled = false
- local autoSellOneByOneThread = nil
- local isAutoFeedEnabled = false
- local autoFeedThread = nil
- local isAutoSubmitHoneyEnabled = false
- local autoSubmitHoneyThread = nil
- local isAutoCollectEnabled = false
- local autoCollectThread = nil
- local MIN_WEIGHT_BY_VARIANT = {
- ["Normal"] = 50,
- ["Gold"] = 40,
- ["Rainbow"] = 30
- }
- local DoNotCollect_Variants = {
- ["Gold"] = false,
- ["Rainbow"] = false
- }
- local DoNotCollect_Mutations = {
- ["Shocked"] = false,
- ["Frozen"] = false,
- ["Wet"] = false,
- ["Chilled"] = false,
- ["Twisted"] = false,
- ["Choc"] = false,
- ["Burnt"] = false,
- ["Moonlit"] = false,
- ["Bloodlit"] = false,
- ["Celestial"] = false,
- ["Zombified"] = false,
- ["Pollinated"] = false,
- ["HoneyGlazed"] = false
- }
- local isAutoPlaceEggEnabled = false
- local autoPlaceEggThread = nil
- local eggIndex = {
- ["Common Egg"] = true,
- ["Uncommon Egg"] = true,
- ["Rare Egg"] = true,
- ["Legendary Egg"] = true,
- ["Mythical Egg"] = true,
- ["Bug Egg"] = true,
- ["Night Egg"] = true,
- ["Bee Egg"] = true
- }
- local isAutoBuyEggEnabled = false
- local autoBuyEggThread = nil
- local Buy_PetEggs = {
- ["Common Egg"] = true,
- ["Uncommon Egg"] = true,
- ["Rare Egg"] = true,
- ["Legendary Egg"] = true,
- ["Mythical Egg"] = true,
- ["Bug Egg"] = true,
- ["Night Egg"] = true,
- ["Bee Egg"] = true
- -- Add/modify as needed
- }
- local Keep_Value = 2000000000 -- 2 billion
- -- Add these tables for the Auto_Sell_Multiple function
- local DoNotSell_Variants = {
- ["Gold"] = false,
- ["Rainbow"] = false
- }
- local DoNotSell_Mutations = {
- ["Shocked"] = false,
- ["Frozen"] = false,
- ["Wet"] = false,
- ["Chilled"] = false,
- ["Twisted"] = false,
- ["Choc"] = false,
- ["Burnt"] = false,
- ["Moonlit"] = false,
- ["Bloodlit"] = false,
- ["Celestial"] = false,
- ["Zombified"] = false,
- ["Pollinated"] = true,
- ["HoneyGlazed"] = false
- }
- local isAutoFavoriteEnabled = false
- local autoFavoriteThread = nil
- local Favorite_Variants = {
- ["Gold"] = false,
- ["Rainbow"] = false
- }
- local Favorite_Mutations = {
- ["Shocked"] = false,
- ["Frozen"] = false,
- ["Wet"] = false,
- ["Chilled"] = false,
- ["Twisted"] = false,
- ["Choc"] = false,
- ["Burnt"] = false,
- ["Moonlit"] = false,
- ["Bloodlit"] = false,
- ["Celestial"] = false,
- ["Zombified"] = false,
- ["Pollinated"] = false,
- ["HoneyGlazed"] = false
- }
- local isSpecialPetDetectorEnabled = true -- Default to enabled
- local specialPetDetectorThread = nil
- local petScreenGui = nil
- local specialPetDetectorInitialized = false
- local specialPetListToggle = {
- ["Dragonfly"] = true,
- ["Raccoon"] = true,
- ["Queen Bee"] = true,
- ["Red Fox"] = true
- }
- -- AUTO-SELL PET VARIABLES
- local isAutoSellPetEnabled = false
- local autoSellPetThread = nil
- -- Maximum weight to sell (in KG)
- local MAX_PET_KG = 5 -- Adjust this value to your preference
- -- Pet selling configuration based on actual pets in the game
- local Sell_Pets = {
- -- Common Pets
- ["Dog"] = true,
- ["Golden Lab"] = true,
- ["Bunny"] = true,
- ["Black Bunny"] = true,
- ["Cat"] = true,
- ["Orange Tabby"] = true,
- ["Deer"] = true,
- ["Spotted Deer"] = true,
- ["Chicken"] = true,
- ["Rooster"] = true,
- ["Pig"] = true,
- -- Uncommon/Rare Pets
- ["Monkey"] = true,
- ["Silver Monkey"] = true,
- ["Turtle"] = true,
- ["Cow"] = true,
- ["Hedgehog"] = true,
- ["Kiwi"] = false,
- ["Mole"] = true,
- ["Frog"] = true,
- ["Echo Frog"] = false,
- ["Bee"] = true,
- -- Legendary/Mythical/Divine Pets
- ["Snail"] = true,
- ["Giant Ant"] = true,
- ["Red Giant Ant"] = true,
- ["Sea Otter"] = true,
- ["Caterpillar"] = true,
- ["Praying Mantis"] = false,
- ["Grey Mouse"] = true,
- ["Brown Mouse"] = true,
- ["Squirrel"] = true,
- ["Blood Hedgehog"] = false,
- ["Honey Bee"] = true,
- ["Petal Bee"] = false,
- ["Golden Bee"] = true,
- ["Bear Bee"] = false,
- --Good Pet
- ["Moon Cat"] = true,
- ["Queen Bee"] = false,
- ["Owl"] = false,
- ["Night Owl"] = false,
- ["Blood Owl"] = false,
- ["Blood Kiwi"] = false,
- ["Polar Bear"] = false,
- ["Red Fox"] = false,
- ["Raccoon"] = false,
- ["Dragonfly"] = false,
- --Un-Obtainable
- ["Chicken Zombie"] = false,
- ["Panda"] = false,
- ["Firefly"] = false,
- ["Red Dragon"] = false
- }
- local isAutoBuySeedEnabled = false
- local autoBuySeedThread = nil
- -- Add this table after your other settings tables
- local Buy_Seeds = {
- ["Carrot"] = false,
- ["Strawberry"] = true,
- ["Blueberry"] = true,
- ["Orange Tulip"] = true,
- ["Tomato"] = true,
- ["Corn"] = true,
- ["Daffodil"] = true,
- ["Watermelon"] = true,
- ["Pumpkin"] = true,
- ["Apple"] = true,
- ["Bamboo"] = false,
- ["Coconut"] = true,
- ["Cactus"] = true,
- ["Dragon Fruit"] = true,
- ["Mango"] = true,
- ["Grape"] = true,
- ["Mushroom"] = true,
- ["Pepper"] = true,
- ["Cacao"] = true
- -- Add more seeds as needed
- }
- local isAutoBuyGearEnabled = false
- local autoBuyGearThread = nil
- -- Add this table after your other settings tables
- local Buy_GearShop = {
- ["Favorite Tool"] = false,
- ["Watering Can"] = true,
- ["Recall Wrench"] = false,
- ["Trowel"] = true,
- ["Basic Sprinkler"] = true,
- ["Advanced Sprinkler"] = true,
- ["Godly Sprinkler"] = true,
- ["Lightning Rod"] = true,
- ["Master Sprinkler"] = true
- -- Set to false for items you don't want to buy
- }
- local isAutoBuyHoneyShopEnabled = false
- local autoBuyHoneyShopThread = nil
- -- Add this configuration table with the actual items from HoneyEventShopData
- local Buy_HoneyShop = {
- -- Seeds and Seed Packs
- ["Bee Egg"] = {buy = true, priority = 1},
- ["Flower Seed Pack"] = {buy = true, priority = 2},
- ["Honey Sprinkler"] = {buy = true, priority = 3},
- -- Gameplay Items
- ["Nectarine"] = {buy = false, priority = 4}, -- This is "Nectarine Seed" in shop display
- ["Hive Fruit"] = {buy = false, priority = 5}, -- This is "Hive Fruit Seed" in shop display
- ["Bee Crate"] = {buy = false, priority = 6},
- -- Cosmetic Items
- ["Honey Comb"] = {buy = false, priority = 7},
- ["Bee Chair"] = {buy = false, priority = 8},
- ["Honey Torch"] = {buy = false, priority = 9},
- ["Honey Walkway"] = {buy = false, priority = 10}
- }
- local isAutoBuyEventEnabled = false
- local autoBuyEventThread = nil
- -- Include ALL items from EventShopData.lua, regardless of DisplayInShop value
- local Buy_EventShop = {
- -- Regular items (DisplayInShop=true)
- ["Mysterious Crate"] = false,
- ["Night Egg"] = true,
- ["Night Seed Pack"] = true,
- ["Blood Banana"] = true,
- ["Moon Melon"] = true,
- ["Star Caller"] = true,
- ["Blood Hedgehog"] = false,
- ["Blood Kiwi"] = true,
- ["Blood Owl"] = false,
- -- Hidden items (DisplayInShop=false, but still purchasable)
- ["Chocolate Carrot"] = true,
- ["Red Lollipop"] = true,
- ["Candy Sunflower"] = true,
- ["Easter Egg"] = true,
- ["Chocolate Sprinkler"] = true,
- ["Candy Blossom"] = true
- }
- -- AUTO-BUY TWILIGHT SHOP VARIABLES
- local isAutoBuyTwilightEnabled = false
- local autoBuyTwilightThread = nil
- -- Items from NightEventShopData.lua
- local Buy_TwilightShop = {
- ["Night Egg"] = true,
- ["Night Seed Pack"] = true,
- ["Twilight Crate"] = true,
- ["Star Caller"] = true,
- ["Moon Cat"] = true,
- ["Celestiberry"] = true, -- Celestiberry Seed
- ["Moon Mango"] = true -- Moon Mango Seed
- }
- -- Add these variables for Auto_Plant
- local isAutoPlantEnabled = false
- local autoPlantThread = nil
- local Plant_Seeds = {
- ["Carrot"] = false,
- ["Strawberry"] = false,
- ["Blueberry"] = false,
- ["Orange Tulip"] = false,
- ["Tomato"] = false,
- ["Corn"] = false,
- ["Daffodil"] = false,
- ["Watermelon"] = false,
- ["Pumpkin"] = false,
- ["Apple"] = false,
- ["Bamboo"] = false,
- ["Coconut"] = true,
- ["Cactus"] = false,
- ["Dragon Fruit"] = true,
- ["Mango"] = true,
- ["Grape"] = true,
- ["Mushroom"] = true,
- ["Pepper"] = true,
- ["Cacao"] = true,
- -- The following seeds might not be available in shop but included for completeness
- ["Pineapple"] = false,
- ["Raspberry"] = false,
- ["Peach"] = false,
- ["Papaya"] = false,
- ["Banana"] = false,
- ["Passionfruit"] = false,
- ["Soul Fruit"] = false,
- ["Cursed Fruit"] = false,
- ["Succulent"] = false,
- ["Cranberry"] = false,
- ["Durian"] = false,
- ["Eggplant"] = false,
- ["Lotus"] = false,
- ["Venus Fly Trap"] = false,
- ["Pear"] = false,
- ["Lemon"] = false,
- ["Cherry Blossom"] = false,
- ["Avocado"] = false,
- ["Nightshade"] = false,
- ["Glowshroom"] = false,
- ["Mint"] = false,
- ["Moonflower"] = false,
- ["Starfruit"] = false,
- ["Moonglow"] = false,
- ["Moon Blossom"] = false,
- ["Chocolate Carrot"] = false,
- ["Red Lollipop"] = false,
- ["Candy Sunflower"] = false,
- ["Easter Egg"] = false,
- ["Candy Blossom"] = false
- }
- local isAutoDeletePlantEnabled = false
- local autoDeletePlantThread = nil
- local Delete_Plants = {
- ["Carrot"] = true,
- ["Strawberry"] = true,
- ["Blueberry"] = true,
- ["Orange Tulip"] = true,
- ["Tomato"] = true,
- ["Corn"] = true,
- ["Daffodil"] = true,
- ["Watermelon"] = true,
- ["Pumpkin"] = true,
- ["Apple"] = true,
- ["Bamboo"] = true,
- ["Coconut"] = false,
- ["Cactus"] = true,
- ["Dragon Fruit"] = false,
- ["Mango"] = false,
- ["Grape"] = false,
- ["Mushroom"] = false,
- ["Pepper"] = false,
- ["Cacao"] = false,
- -- The following seeds might not be available in shop but included for completeness
- ["Pineapple"] = true,
- ["Raspberry"] = true,
- ["Peach"] = true,
- ["Papaya"] = true,
- ["Banana"] = false,
- ["Passionfruit"] = true,
- ["Soul Fruit"] = false,
- ["Cursed Fruit"] = false,
- ["Succulent"] = false,
- ["Cranberry"] = false,
- ["Durian"] = false,
- ["Eggplant"] = false,
- ["Lotus"] = false,
- ["Venus Fly Trap"] = false,
- ["Pear"] = false,
- ["Lemon"] = false,
- ["Cherry Blossom"] = false,
- ["Avocado"] = false,
- ["Nightshade"] = false,
- ["Glowshroom"] = false,
- ["Mint"] = false,
- ["Moonflower"] = false,
- ["Starfruit"] = false,
- ["Moonglow"] = false,
- ["Moon Blossom"] = false,
- ["Chocolate Carrot"] = false,
- ["Red Lollipop"] = false,
- ["Candy Sunflower"] = false,
- ["Easter Egg"] = false,
- ["Candy Blossom"] = false
- }
- local playerGui = player:WaitForChild("PlayerGui")
- local priceGui = Instance.new("ScreenGui")
- priceGui.Name = "PriceCalculatorGui"
- priceGui.ResetOnSpawn = false
- priceGui.Parent = playerGui
- local priceFrame = Instance.new("Frame")
- priceFrame.Name = "PriceFrame"
- priceFrame.Size = UDim2.new(0, 350, 0, 200)
- priceFrame.AnchorPoint = Vector2.new(0.5, 0)
- priceFrame.Position = UDim2.new(0.1,85, 0, 0.0,1, 0)
- priceFrame.BackgroundColor3 = Color3.new(0, 0, 0)
- priceFrame.BackgroundTransparency = 0.9
- priceFrame.Parent = priceGui
- local priceLabel = Instance.new("TextLabel")
- priceLabel.Name = "PriceLabel"
- priceLabel.Size = UDim2.new(1, -10, 1, -10)
- priceLabel.Position = UDim2.new(0, 5, 0, 5)
- priceLabel.BackgroundTransparency = 1
- priceLabel.TextColor3 = Color3.new(1, 1, 1)
- priceLabel.TextScaled = true
- priceLabel.TextWrapped = true
- priceLabel.Font = Enum.Font.SourceSansBold
- priceLabel.Text = ""
- priceLabel.Parent = priceFrame
- local ignoreGear = {
- ["Watering Can"] = true,
- ["Recall Wrench"] = true,
- ["Trowel"] = true,
- ["Basic Sprinkler"] = true,
- ["Advanced Sprinkler"]= true,
- ["Godly Sprinkler"] = true,
- ["Lightning Rod"] = true,
- ["Master Sprinkler"] = true,
- }
- local function formatNumber(n)
- local sign = (n < 0) and "-" or ""
- local absn = math.abs(n)
- local suffix = ""
- if absn >= 1e12 then
- n = n/1e12; suffix = "T"
- elseif absn >= 1e9 then
- n = n/1e9; suffix = "B"
- elseif absn >= 1e6 then
- n = n/1e6; suffix = "M"
- end
- local i = math.floor(math.abs(n))
- local f = math.abs(n) - i
- local frac = (f > 0) and ("%.2f"):format(f):sub(2) or ""
- local s = tostring(i)
- while true do
- local count
- s, count = s:gsub("^(-?%d+)(%d%d%d)", "%1,%2")
- if count == 0 then break end
- end
- return sign .. s .. frac .. suffix
- end
- local function updatePrice(tool)
- if not tool or not tool:IsA("Tool") then
- priceLabel.Text = ""
- return
- end
- local t = tool:GetAttribute("ItemType")
- if t == "Seed" then
- priceLabel.Text = ""
- return
- end
- if ignoreGear[tool.Name] then
- priceLabel.Text = ""
- return
- end
- if t == "Pet" then
- priceLabel.Text = "Pet Price: " .. formatNumber(CalculatePetValue(tool))
- else
- priceLabel.Text = "Fruit Price: " .. formatNumber(CalculatePlantValue(tool))
- end
- end
- local function hookTool(tool)
- if not tool:IsA("Tool") then return end
- tool.Equipped:Connect(function() updatePrice(tool) end)
- tool.Unequipped:Connect(function() updatePrice(nil) end)
- end
- for _, tool in ipairs(player.Backpack:GetChildren()) do hookTool(tool) end
- player.Backpack.ChildAdded:Connect(hookTool)
- if player.Character then
- for _, tool in ipairs(player.Character:GetChildren()) do hookTool(tool) end
- end
- player.CharacterAdded:Connect(function(char)
- for _, tool in ipairs(char:GetChildren()) do hookTool(tool) end
- end)
- -- Function to initialize and start the pet detector
- function Initialize_Special_Pet_Detector()
- if specialPetDetectorInitialized then return end
- specialPetDetectorInitialized = true
- -- Create GUI if it doesn't exist
- if not petScreenGui then
- petScreenGui = Instance.new("ScreenGui")
- petScreenGui.Name = "SpecialPetDetectorScreen"
- petScreenGui.ResetOnSpawn = false
- petScreenGui.IgnoreGuiInset = true
- petScreenGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
- petScreenGui.DisplayOrder = 999
- -- Create green background
- local frame = Instance.new("Frame")
- frame.Size = UDim2.new(1, 0, 1, 0)
- frame.BackgroundColor3 = Color3.fromRGB(0, 255, 0) -- Green
- frame.BackgroundTransparency = 0
- frame.BorderSizePixel = 0
- frame.Name = "GreenScreen"
- frame.Parent = petScreenGui
- -- Add title label
- local titleLabel = Instance.new("TextLabel")
- titleLabel.Size = UDim2.new(1, 0, 0, 60)
- titleLabel.Position = UDim2.new(0, 0, 0.1, 0)
- titleLabel.BackgroundTransparency = 1
- titleLabel.Font = Enum.Font.SourceSansBold
- titleLabel.TextSize = 40
- titleLabel.TextWrapped = true
- titleLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
- titleLabel.Text = "SPECIAL PET DETECTED"
- titleLabel.TextStrokeTransparency = 0
- titleLabel.TextStrokeColor3 = Color3.fromRGB(0, 0, 0)
- titleLabel.Name = "TitleLabel"
- titleLabel.Parent = frame
- -- Add pet list
- local petListLabel = Instance.new("TextLabel")
- petListLabel.Size = UDim2.new(0.8, 0, 0.5, 0)
- petListLabel.Position = UDim2.new(0.1, 0, 0.25, 0)
- petListLabel.BackgroundTransparency = 1
- petListLabel.Font = Enum.Font.SourceSansBold
- petListLabel.TextSize = 30
- petListLabel.TextWrapped = true
- petListLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
- petListLabel.Text = "Checking for pets..."
- petListLabel.TextStrokeTransparency = 0
- petListLabel.TextStrokeColor3 = Color3.fromRGB(0, 0, 0)
- petListLabel.Name = "PetList"
- petListLabel.Parent = frame
- petScreenGui.Parent = game:GetService("Players").LocalPlayer:WaitForChild("PlayerGui")
- end
- -- Start background detection thread (only one)
- if not specialPetDetectorThread then
- specialPetDetectorThread = spawn(function()
- while true do -- Keep checking pets regardless of toggle (only visibility changes)
- pcall(function()
- local DataService = require(ReplicatedStorage.Modules.DataService)
- local playerData = DataService:GetData()
- local foundSpecialPet = false
- local detectedPets = {}
- if playerData and playerData.PetsData and playerData.PetsData.PetInventory and
- playerData.PetsData.PetInventory.Data then
- -- Loop through all pets in inventory
- for _, petData in pairs(playerData.PetsData.PetInventory.Data) do
- if petData and petData.PetType and specialPetListToggle[petData.PetType] then
- foundSpecialPet = true
- detectedPets[petData.PetType] = (detectedPets[petData.PetType] or 0) + 1
- end
- end
- end
- -- Update UI based on results
- if foundSpecialPet and petScreenGui then
- -- Only show if toggle is enabled
- if isSpecialPetDetectorEnabled then
- petScreenGui.Enabled = true
- -- Update pet list text
- local petListText = "Found Special Pets:\n\n"
- for petType, count in pairs(detectedPets) do
- petListText = petListText .. petType .. " x" .. count .. "\n"
- end
- if petScreenGui and petScreenGui.GreenScreen and petScreenGui.GreenScreen.PetList then
- petScreenGui.GreenScreen.PetList.Text = petListText
- end
- end
- else
- if petScreenGui then
- petScreenGui.Enabled = false
- end
- end
- end)
- task.wait(5) -- Check every 5 seconds
- end
- end)
- end
- end
- -- This function ONLY toggles visibility, doesn't restart detection
- function Toggle_Pet_Screen_Visibility()
- isSpecialPetDetectorEnabled = not isSpecialPetDetectorEnabled
- if petScreenGui then
- petScreenGui.Enabled = isSpecialPetDetectorEnabled
- end
- return isSpecialPetDetectorEnabled
- end
- -- Add this T key toggle function with your other input listeners
- game:GetService("UserInputService").InputBegan:Connect(function(input, gameProcessed)
- if gameProcessed then return end
- if input.KeyCode == Enum.KeyCode.T then
- Toggle_Pet_Screen_Visibility()
- end
- end)
- -- This function is called by the main loop to start the detector once
- function Auto_Special_Pet_Detector()
- if not specialPetDetectorInitialized then
- Initialize_Special_Pet_Detector()
- end
- return isSpecialPetDetectorEnabled
- end
- function Auto_ToggleUI()
- isAutoToggleUIEnabled = not isAutoToggleUIEnabled
- if isAutoToggleUIEnabled then
- autoToggleUIThread = spawn(function()
- while isAutoToggleUIEnabled do
- pcall(function()
- -- Check and toggle Honey UI
- local honeyUI = game:GetService("Players").LocalPlayer.PlayerGui:FindFirstChild("Honey_UI")
- if honeyUI and honeyUI:FindFirstChild("Frame") and honeyUI.Frame.Visible == false then
- honeyUI.Frame.Visible = true
- task.wait(1)
- game:service'VirtualInputManager':SendKeyEvent(true, "ButtonR2", false, game)
- end
- -- Check and toggle Teleport UI elements
- local teleportUI = game:GetService("Players").LocalPlayer.PlayerGui:FindFirstChild("Teleport_UI")
- if teleportUI and teleportUI:FindFirstChild("Frame") then
- -- Toggle Gear visibility
- if teleportUI.Frame:FindFirstChild("Gear") and teleportUI.Frame.Gear.Visible == false then
- teleportUI.Frame.Gear.Visible = true
- task.wait(1)
- game:service'VirtualInputManager':SendKeyEvent(true, "ButtonR2", false, game)
- end
- -- Toggle Pets visibility
- if teleportUI.Frame:FindFirstChild("Pets") and teleportUI.Frame.Pets.Visible == false then
- teleportUI.Frame.Pets.Visible = true
- task.wait(1)
- game:service'VirtualInputManager':SendKeyEvent(true, "ButtonR2", false, game)
- end
- end
- end)
- -- Check UI elements every 3 seconds
- task.wait(60)
- end
- autoToggleUIThread = nil
- end)
- else
- if autoToggleUIThread then
- task.cancel(autoToggleUIThread)
- end
- autoToggleUIThread = nil
- end
- return isAutoToggleUIEnabled
- end
- -- Create a function to check for special plants
- function CheckForSpecialPlants()
- local playerPlot = GetFarm(player)
- if playerPlot and playerPlot:FindFirstChild("Important") and
- playerPlot.Important:FindFirstChild("Plants_Physical") then
- for _, plant in ipairs(playerPlot.Important.Plants_Physical:GetChildren()) do
- if plant.Name == "Candy Blossom" then -- can add more plants ( example if plant.Name == "Candy Blossom" or plant.Name == "Other Special Plant" then) )
- hasSpecialPlant = true
- return true
- end
- end
- end
- return false
- end
- -- TOGGLE & RUN AUTO-COLLECT
- function Auto_Collect()
- isAutoCollectEnabled = not isAutoCollectEnabled
- if isAutoCollectEnabled then
- local cachedPrompts = {}
- local scanTimer = 0
- local isPaused = false
- -- Set up notification listener for inventory full
- local notificationConnection
- notificationConnection = game.ReplicatedStorage:WaitForChild("GameEvents").Notification.OnClientEvent:Connect(function(message)
- if isAutoCollectEnabled and typeof(message) == "string" and
- (message:find("Inventory is full") or message:find("Max backpack")) then
- -- Set paused flag and schedule resume after 10 seconds
- isPaused = true
- task.delay(10, function()
- isPaused = false
- end)
- end
- end)
- autoCollectThread = spawn(function()
- while isAutoCollectEnabled do
- -- Skip collection if paused due to full inventory
- if not isPaused then
- pcall(function()
- -- only refresh prompts every 15 loops (~7.5s)
- scanTimer = scanTimer + 1
- if #cachedPrompts == 0 or scanTimer >= 15 then
- cachedPrompts = CollectionService:GetTagged("CollectPrompt")
- scanTimer = 0
- end
- -- collect low-weight crops
- local toCollect = {}
- for _, prompt in ipairs(cachedPrompts) do
- if prompt:IsDescendantOf(farmRoot) then
- local model = prompt.Parent and prompt.Parent.Parent
- if model and model:IsA("Model") then
- -- Get variant and check it's not excluded
- local variant = model:FindFirstChild("Variant")
- local variantValue = variant and variant.Value or "Normal"
- if not DoNotCollect_Variants[variantValue] then
- -- Use MutationHandler to check mutations
- local mutationString = ""
- local success = pcall(function()
- mutationString = MutationHandler:GetMutationsAsString(model)
- end)
- -- Check if any mutation is in the exclusion list
- local shouldCollect = true
- if success and mutationString ~= "" then
- for mutation, excluded in pairs(DoNotCollect_Mutations) do
- if excluded and mutationString:find(mutation) then
- shouldCollect = false
- break
- end
- end
- end
- -- Check weight and collect if appropriate
- if shouldCollect then
- local w = (model:FindFirstChild("Weight") and model.Weight.Value) or 0
- local variantThreshold = MIN_WEIGHT_BY_VARIANT[variantValue]
- if w <= variantThreshold then
- table.insert(toCollect, model)
- end
- end
- end
- end
- end
- end
- if #toCollect > 0 then
- for _, model in ipairs(toCollect) do
- Remotes.Crops.Collect.send({model})
- task.wait(0.1)
- end
- end
- end)
- end
- task.wait(1)
- end
- -- Clean up notification connection
- if notificationConnection then
- notificationConnection:Disconnect()
- end
- autoCollectThread = nil
- end)
- else
- autoCollectThread = nil
- end
- return isAutoCollectEnabled
- end
- -- TOGGLE & RUN AUTO-SELL
- --[[function Auto_Sell()
- isAutoSellEnabled = not isAutoSellEnabled
- if isAutoSellEnabled then
- -- Set up notification listener
- local notificationConnection
- notificationConnection = game.ReplicatedStorage:WaitForChild("GameEvents").Notification.OnClientEvent:Connect(function(message)
- if isAutoSellEnabled and typeof(message) == "string" and
- (message:find("Inventory is full") or message:find("Max backpack")) then
- pcall(function()
- -- Ensure character and HRP exist
- local char = player.Character or player.CharacterAdded:Wait()
- local hrp = char:FindFirstChild("HumanoidRootPart")
- local humanoid = char:FindFirstChild("Humanoid")
- if not hrp or not humanoid then return end
- -- Find a sell stand
- local standsFolder = workspace:WaitForChild("NPCS"):WaitForChild("Sell Stands")
- local closestStand = nil
- local closestDist = math.huge
- local closestPart = nil
- -- Find the closest sell stand
- for _, stand in ipairs(standsFolder:GetChildren()) do
- local targetPart
- if stand:IsA("Model") then
- targetPart = stand.PrimaryPart or stand:FindFirstChildWhichIsA("BasePart")
- elseif stand:IsA("BasePart") then
- targetPart = stand
- end
- if targetPart then
- local dist = (hrp.Position - targetPart.Position).Magnitude
- if dist < closestDist then
- closestStand = stand
- closestDist = dist
- closestPart = targetPart
- end
- end
- end
- if not closestPart then return end
- -- Original position for teleporting back
- local originalCFrame = hrp.CFrame
- local originalState = humanoid:GetState()
- -- Check if already near a sell stand (within 15 studs)
- local isNearStand = closestDist <= 15
- -- Only teleport if not already near
- if not isNearStand then
- -- Store the current state
- local currentPlatformStand = humanoid.PlatformStand
- -- Teleport to the front of the stand with proper orientation
- local standCF = closestPart.CFrame
- local lookAt = (standCF.Position - Vector3.new(standCF.Position.X, hrp.Position.Y, standCF.Position.Z)).Unit
- local targetCF = CFrame.new(standCF.Position + Vector3.new(-3, 0, 5))
- -- Teleport
- hrp.CFrame = targetCF
- -- Reset humanoid state to fix animation
- humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
- task.wait(0.1)
- humanoid:ChangeState(Enum.HumanoidStateType.Running)
- humanoid.PlatformStand = false
- task.wait(0.5) -- Wait for teleport and animation reset
- end
- -- Try submitting all plants first if needed
- task.spawn(function()
- pcall(function()
- game:GetService("ReplicatedStorage").GameEvents.NightQuestRemoteEvent:FireServer("SubmitAllPlants")
- end)
- end)
- task.wait(0.5)
- -- Sell
- sellRemote:FireServer()
- task.wait(0.5)
- -- Return to original position only if we teleported
- if not isNearStand then
- -- Teleport back
- hrp.CFrame = originalCFrame
- -- Reset state again
- humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
- task.wait(0.1)
- humanoid:ChangeState(Enum.HumanoidStateType.Running)
- humanoid.PlatformStand = false
- end
- end)
- end
- end)
- autoSellThread = spawn(function()
- while isAutoSellEnabled do
- task.wait(1)
- end
- -- Clean up notification connection when disabled
- if notificationConnection then
- notificationConnection:Disconnect()
- end
- autoSellThread = nil
- end)
- else
- autoSellThread = nil
- end
- return isAutoSellEnabled
- end]]
- function Auto_Sell_Multiple()
- isAutoSellOneByOneEnabled = not isAutoSellOneByOneEnabled
- if isAutoSellOneByOneEnabled then
- autoSellOneByOneThread = spawn(function()
- while isAutoSellOneByOneEnabled do
- pcall(function()
- -- Get player data to check for items
- local DataService = require(ReplicatedStorage.Modules.DataService)
- local playerData = DataService:GetData()
- if not playerData or not playerData.InventoryData then return end
- -- Find items we can sell (not seeds, not favorites)
- local itemsToSell = {}
- for uuid, itemData in pairs(playerData.InventoryData) do
- if itemData.ItemType == "Holdable" and itemData.ItemData then
- -- Skip favorited items
- if not itemData.ItemData.IsFavorite then
- -- Check if item has a protected variant
- local shouldSkip = false
- -- Check for variants
- if itemData.ItemData.Variant and DoNotSell_Variants[itemData.ItemData.Variant] == true then
- shouldSkip = true
- end
- -- Check for mutations
- if not shouldSkip and itemData.ItemData.MutationString then
- for mutation, excluded in pairs(DoNotSell_Mutations) do
- if excluded and itemData.ItemData.MutationString:find(mutation) then
- shouldSkip = true
- break
- end
- end
- end
- -- Only proceed if item is not to be skipped
- if not shouldSkip then
- local tool = nil
- for _, t in pairs(player.Backpack:GetChildren()) do
- if t:IsA("Tool") and t:GetAttribute("ITEM_UUID") == uuid then
- tool = t
- break
- end
- end
- if not tool and player.Character then
- for _, t in pairs(player.Character:GetChildren()) do
- if t:IsA("Tool") and t:GetAttribute("ITEM_UUID") == uuid then
- tool = t
- break
- end
- end
- end
- -- If we found the tool, check its price
- if tool then
- -- Calculate the item's value
- local itemValue = 0
- if tool:GetAttribute("ItemType") == "Pet" then
- itemValue = CalculatePetValue(tool)
- else
- itemValue = CalculatePlantValue(tool)
- end
- -- Only sell if value is below Keep_Value
- if itemValue < Keep_Value then
- table.insert(itemsToSell, tool)
- end
- end
- end
- end
- end
- end
- -- Only teleport and sell if we found items to sell
- if #itemsToSell > 10 then
- -- Ensure character and HRP exist
- local char = player.Character or player.CharacterAdded:Wait()
- local hrp = char:FindFirstChild("HumanoidRootPart")
- local humanoid = char:FindFirstChild("Humanoid")
- if not hrp or not humanoid then return end
- -- Find a sell stand
- local standsFolder = workspace:WaitForChild("NPCS"):WaitForChild("Sell Stands")
- local closestStand = nil
- local closestDist = math.huge
- local closestPart = nil
- -- Find the closest sell stand
- for _, stand in ipairs(standsFolder:GetChildren()) do
- local targetPart
- if stand:IsA("Model") then
- targetPart = stand.PrimaryPart or stand:FindFirstChildWhichIsA("BasePart")
- elseif stand:IsA("BasePart") then
- targetPart = stand
- end
- if targetPart then
- local dist = (hrp.Position - targetPart.Position).Magnitude
- if dist < closestDist then
- closestStand = stand
- closestDist = dist
- closestPart = targetPart
- end
- end
- end
- if not closestPart then return end
- -- Original position for teleporting back
- local originalCFrame = hrp.CFrame
- local originalState = humanoid:GetState()
- -- Check if already near a sell stand (within 5 studs)
- local isNearStand = closestDist <= 5
- -- Only teleport if not already near
- if not isNearStand then
- -- Store the current state
- local currentPlatformStand = humanoid.PlatformStand
- -- Teleport to the front of the stand with proper orientation
- local standCF = closestPart.CFrame
- local targetCF = CFrame.new(standCF.Position + Vector3.new(-3, 0, 5))
- -- Teleport
- hrp.CFrame = targetCF
- -- Reset humanoid state to fix animation
- humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
- task.wait(0.1)
- humanoid:ChangeState(Enum.HumanoidStateType.Running)
- humanoid.PlatformStand = false
- task.wait(0.5) -- Wait for teleport and animation reset
- end
- -- Sell all items found, one by one
- for _, tool in ipairs(itemsToSell) do
- if tool.Parent ~= player.Character then
- tool.Parent = player.Character
- task.wait(0.01)
- end
- sell_One_Remote:FireServer()
- task.wait(0.1) -- Small delay between sells to avoid flooding
- end
- -- Return to original position only if we teleported
- if not isNearStand then
- -- Teleport back
- hrp.CFrame = originalCFrame
- -- Reset state again
- humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
- task.wait(0.1)
- humanoid:ChangeState(Enum.HumanoidStateType.Running)
- humanoid.PlatformStand = false
- end
- end
- end)
- task.wait(1) -- Wait before next check
- end
- autoSellOneByOneThread = nil
- end)
- else
- if autoSellOneByOneThread then
- task.cancel(autoSellOneByOneThread)
- end
- autoSellOneByOneThread = nil
- end
- return isAutoSellOneByOneEnabled
- end
- -- AUTO-FAVORITE FUNCTION
- function Auto_Favorite()
- isAutoFavoriteEnabled = not isAutoFavoriteEnabled
- if isAutoFavoriteEnabled then
- autoFavoriteThread = spawn(function()
- while isAutoFavoriteEnabled do
- pcall(function()
- -- Get inventory data
- local DataService = require(ReplicatedStorage.Modules.DataService)
- local playerData = DataService:GetData()
- if playerData and playerData.InventoryData then
- for uuid, record in pairs(playerData.InventoryData) do
- -- Only check Holdable items
- if record.ItemType == "Holdable" and record.ItemData then
- -- Skip already favorited items
- if record.ItemData.IsFavorite ~= true then
- -- Find the tool object in player's inventory
- local tool = nil
- local backpack = player.Backpack
- for _, t in pairs(backpack:GetChildren()) do
- if t:IsA("Tool") and t:GetAttribute("ITEM_UUID") == uuid then
- tool = t
- break
- end
- end
- if tool then
- local shouldFavorite = false
- local reason = ""
- -- Priority 1: Check for mutations (highest priority)
- local hasMutation = false
- if record.ItemData.MutationString then
- for mutation, shouldFavoriteMutation in pairs(Favorite_Mutations) do
- if shouldFavoriteMutation and record.ItemData.MutationString:find(mutation) then
- hasMutation = true
- shouldFavorite = true
- reason = "mutation"
- break
- end
- end
- end
- -- Priority 2: Check item value if not already favorited by mutation
- if not shouldFavorite then
- local itemValue = 0
- if tool:GetAttribute("ItemType") == "Pet" then
- itemValue = CalculatePetValue(tool)
- else
- itemValue = CalculatePlantValue(tool)
- end
- if itemValue >= Keep_Value then
- shouldFavorite = true
- reason = "high value"
- end
- end
- -- Priority 3: Check for special variant (lowest priority)
- if not shouldFavorite then
- local hasSpecialVariant = record.ItemData.Variant ~= nil and
- Favorite_Variants[record.ItemData.Variant] == true
- if hasSpecialVariant then
- shouldFavorite = true
- reason = "variant"
- end
- end
- -- Favorite the item if any condition was met
- if shouldFavorite then
- -- Get the Favorite_Item remote
- local favoriteRemote = ReplicatedStorage:WaitForChild("GameEvents")
- :WaitForChild("Favorite_Item")
- favoriteRemote:FireServer(tool)
- task.wait(0.1) -- Wait to avoid flooding the server
- end
- end
- end
- end
- end
- end
- end)
- task.wait(0.1) -- Check frequently
- end
- autoFavoriteThread = nil
- end)
- else
- autoFavoriteThread = nil
- end
- return isAutoFavoriteEnabled
- end
- -- AUTO-BUY EGG FUNCTION
- function Auto_BuyEgg()
- isAutoBuyEggEnabled = not isAutoBuyEggEnabled
- if isAutoBuyEggEnabled then
- autoBuyEggThread = spawn(function()
- while isAutoBuyEggEnabled do
- pcall(function()
- local DataService = require(ReplicatedStorage.Modules.DataService)
- local playerData = DataService:GetData()
- if playerData and playerData.PetEggStock and playerData.PetEggStock.Stocks then
- for eggIndex, eggData in pairs(playerData.PetEggStock.Stocks) do
- -- ALERT: Legendary or Bug Egg in stock
- if (eggData.EggName == "Bee Egg" or eggData.EggName == "Bug Egg" or
- eggData.EggName == "Night Egg") and eggData.Stock > 0 then
- -- Send webhook notification
- pcall(function()
- request({
- Url = webhookUrl,
- Method = "POST",
- Headers = { ["Content-Type"] = "application/json" },
- Body = HttpService:JSONEncode({
- embeds = {{
- title = "Grow A Garden Alert",
- color = 16753920,
- fields = {
- { name = "Egg", value = eggData.EggName },
- { name = "Stock", value = tostring(eggData.Stock) }
- }
- }}
- })
- })
- end)
- end
- -- Check if this egg is on our buy list and in stock
- if Buy_PetEggs[eggData.EggName] and eggData.Stock > 0 then
- -- Try to buy all available stock
- local stockAmount = eggData.Stock
- for i = 1, stockAmount do
- -- Make purchase request
- ReplicatedStorage.GameEvents.BuyPetEgg:FireServer(eggIndex)
- -- Wait between purchases
- task.wait(0.5)
- -- Check if purchase was successful by checking updated stock
- local updatedData = DataService:GetData()
- if updatedData and updatedData.PetEggStock and
- updatedData.PetEggStock.Stocks[eggIndex] then
- local newStock = updatedData.PetEggStock.Stocks[eggIndex].Stock
- if newStock < stockAmount then
- stockAmount = newStock -- Update remaining stock
- if stockAmount == 0 then break end
- else
- task.wait(1)
- break
- end
- end
- end
- end
- end
- end
- end)
- -- Check for eggs every 5 seconds (more frequent than before)
- task.wait(5)
- end
- autoBuyEggThread = nil
- end)
- else
- if autoBuyEggThread then
- task.cancel(autoBuyEggThread)
- autoBuyEggThread = nil
- end
- end
- return isAutoBuyEggEnabled
- end
- -- AUTO-BUY GEAR FUNCTION
- function Auto_BuyGear()
- isAutoBuyGearEnabled = not isAutoBuyGearEnabled
- if isAutoBuyGearEnabled then
- autoBuyGearThread = spawn(function()
- while isAutoBuyGearEnabled do
- pcall(function()
- local DataService = require(ReplicatedStorage.Modules.DataService)
- local playerData = DataService:GetData()
- if playerData and playerData.GearStock and playerData.GearStock.Stocks then
- -- Track which items we've purchased in this cycle
- local purchasedItems = {}
- for itemName, stockData in pairs(playerData.GearStock.Stocks) do
- -- ALERT: Master Sprinkler in stock
- if itemName == "Master Sprinkler" and stockData.Stock > 0 then
- -- Send webhook notification
- pcall(function()
- request({
- Url = webhookUrl,
- Method = "POST",
- Headers = { ["Content-Type"] = "application/json" },
- Body = HttpService:JSONEncode({
- embeds = {{
- title = "Grow A Garden Alert",
- color = 65280,
- fields = {
- { name = "Item", value = itemName },
- { name = "Stock", value = tostring(stockData.Stock) }
- }
- }}
- })
- })
- end)
- end
- -- Check if this gear is on our buy list and in stock
- if Buy_GearShop[itemName] == true and stockData.Stock > 0 then
- -- Try to buy all available stock
- local stockAmount = stockData.Stock
- for i = 1, stockAmount do
- -- Make purchase request
- ReplicatedStorage.GameEvents.BuyGearStock:FireServer(itemName)
- -- Wait between purchases
- task.wait(0.5)
- -- Check if purchase was successful by checking updated stock
- local updatedData = DataService:GetData()
- if updatedData and updatedData.GearStock and
- updatedData.GearStock.Stocks[itemName] then
- local newStock = updatedData.GearStock.Stocks[itemName].Stock
- if newStock < stockAmount then
- table.insert(purchasedItems, itemName)
- stockAmount = newStock -- Update remaining stock
- if stockAmount == 0 then break end
- else
- task.wait(1)
- break
- end
- end
- end
- end
- end
- -- Submit plants quest only once after we've made purchases
- if #purchasedItems > 0 then
- task.wait(1)
- pcall(function()
- game:GetService("ReplicatedStorage").GameEvents.NightQuestRemoteEvent:FireServer("SubmitAllPlants")
- end)
- end
- end
- end)
- -- Check for gear every 5 seconds
- task.wait(5)
- end
- autoBuyGearThread = nil
- end)
- else
- if autoBuyGearThread then
- task.cancel(autoBuyGearThread)
- autoBuyGearThread = nil
- end
- end
- return isAutoBuyGearEnabled
- end
- -- AUTO-BUY EVENT SHOP FUNCTION
- function Auto_BuyEvent()
- isAutoBuyEventEnabled = not isAutoBuyEventEnabled
- if isAutoBuyEventEnabled then
- autoBuyEventThread = spawn(function()
- while isAutoBuyEventEnabled do
- pcall(function()
- -- Check if it's blood moon
- local isBloodMoon = workspace:GetAttribute("BloodMoonEvent") or false
- -- Only run during blood moon
- if isBloodMoon then
- -- Get Event Shop data
- local DataService = require(ReplicatedStorage.Modules.DataService)
- local playerData = DataService:GetData()
- if playerData and playerData.EventShopStock and playerData.EventShopStock.Stocks then
- -- Check current Blood Kiwi count in inventory
- local bloodKiwiCount = 0
- if playerData.InventoryData then
- for _, itemData in pairs(playerData.InventoryData) do
- if itemData.ItemType == "Holdable" and itemData.ItemData and
- itemData.ItemData.ItemName == "Blood Kiwi" then
- bloodKiwiCount = bloodKiwiCount + 1
- end
- end
- end
- for itemName, stockData in pairs(playerData.EventShopStock.Stocks) do
- -- Skip Blood Kiwi if we already have 8 or more
- if itemName == "Blood Kiwi" and bloodKiwiCount >= 8 then
- continue
- end
- -- For ANY item in stock, if we don't have it in our Buy_EventShop table yet, add it
- if Buy_EventShop[itemName] == nil then
- Buy_EventShop[itemName] = true
- end
- -- Special alert for Divine rarity items or any item with Stock > 0
- if stockData.Stock > 0 then
- -- Send more detailed webhook for rarer items
- local eventItem = require(ReplicatedStorage.Data:WaitForChild("EventShopData"))[itemName]
- local rarity = eventItem and eventItem.SeedRarity or "Unknown"
- if rarity == "Divine" or rarity == "Legendary" or rarity == "Mythical" then
- pcall(function()
- request({
- Url = webhookUrl,
- Method = "POST",
- Headers = { ["Content-Type"] = "application/json" },
- Body = HttpService:JSONEncode({
- embeds = {{
- title = "Grow A Garden Alert: " .. rarity .. " Item",
- color = (rarity == "Divine") and 16711680 or 16776960,
- fields = {
- { name = "Event Item", value = itemName },
- { name = "Rarity", value = rarity },
- { name = "Stock", value = tostring(stockData.Stock) }
- }
- }}
- })
- })
- end)
- end
- end
- -- Attempt to buy if in our list and in stock
- if Buy_EventShop[itemName] == true and stockData.Stock > 0 then
- -- Try to buy all available stock
- local stockAmount = stockData.Stock
- for i = 1, stockAmount do
- -- Make purchase request
- ReplicatedStorage.GameEvents.BuyEventShopStock:FireServer(itemName)
- ReplicatedStorage.GameEvents.BuyEventShopStock:FireServer("Candy Blossom")
- ReplicatedStorage.GameEvents.BuyEventShopStock:FireServer("Chocolate Sprinkler")
- -- Wait between purchases
- task.wait(0.5)
- -- Check if purchase was successful
- local updatedData = DataService:GetData()
- if updatedData and updatedData.EventShopStock and
- updatedData.EventShopStock.Stocks[itemName] then
- local newStock = updatedData.EventShopStock.Stocks[itemName].Stock
- if newStock < stockAmount then
- stockAmount = newStock -- Update remaining stock
- if stockAmount == 0 then break end
- else
- task.wait(1)
- break
- end
- end
- end
- end
- end
- end
- end
- end)
- -- Check for event shop items more frequently (once per second)
- task.wait(1)
- end
- autoBuyEventThread = nil
- end)
- else
- if autoBuyEventThread then
- task.cancel(autoBuyEventThread)
- autoBuyEventThread = nil
- end
- end
- return isAutoBuyEventEnabled
- end
- -- AUTO-BUY TWILIGHT SHOP FUNCTION
- function Auto_BuyTwilight()
- isAutoBuyTwilightEnabled = not isAutoBuyTwilightEnabled
- if isAutoBuyTwilightEnabled then
- autoBuyTwilightThread = spawn(function()
- while isAutoBuyTwilightEnabled do
- pcall(function()
- -- Check if it's regular night (not blood moon)
- local isNight = workspace:GetAttribute("NightEvent") or false
- local isBloodMoon = workspace:GetAttribute("BloodMoonEvent") or false
- -- Only run during regular night (when isNight is true and isBloodMoon is false)
- if isNight and not isBloodMoon then
- -- Get NightEventShop data
- local DataService = require(ReplicatedStorage.Modules.DataService)
- local playerData = DataService:GetData()
- if playerData and playerData.NightEventShopStock and playerData.NightEventShopStock.Stocks then
- for itemName, stockData in pairs(playerData.NightEventShopStock.Stocks) do
- -- Special alert for rare items in stock
- if stockData.Stock > 0 then
- -- Get item data from ReplicatedStorage
- local NightEventShopData = require(ReplicatedStorage.Data:WaitForChild("NightEventShopData"))
- local itemInfo = NightEventShopData[itemName]
- if itemInfo then
- local rarity = itemInfo.SeedRarity or "Unknown"
- -- Send webhook for rare items
- if rarity == "Divine" or rarity == "Mythical" or rarity == "Legendary" then
- pcall(function()
- request({
- Url = webhookUrl,
- Method = "POST",
- Headers = { ["Content-Type"] = "application/json" },
- Body = HttpService:JSONEncode({
- embeds = {{
- title = "Grow A Garden Alert: Twilight Shop",
- color = (rarity == "Divine") and 16711680 or 16776960,
- fields = {
- { name = "Item", value = itemName },
- { name = "Rarity", value = rarity },
- { name = "Stock", value = tostring(stockData.Stock) }
- }
- }}
- })
- })
- end)
- end
- end
- end
- -- Attempt to buy if in our list and in stock
- if Buy_TwilightShop[itemName] == true and stockData.Stock > 0 then
- -- Try to buy all available stock
- local stockAmount = stockData.Stock
- for i = 1, stockAmount do
- -- Make purchase request
- ReplicatedStorage.GameEvents.BuyNightEventShopStock:FireServer(itemName)
- -- Wait between purchases
- task.wait(0.5)
- -- Check if purchase was successful
- local updatedData = DataService:GetData()
- if updatedData and updatedData.NightEventShopStock and
- updatedData.NightEventShopStock.Stocks[itemName] then
- local newStock = updatedData.NightEventShopStock.Stocks[itemName].Stock
- if newStock < stockAmount then
- stockAmount = newStock -- Update remaining stock
- if stockAmount == 0 then break end
- else
- task.wait(1)
- break
- end
- end
- end
- end
- end
- end
- end
- end)
- -- Check for twilight shop items every second
- task.wait(1)
- end
- autoBuyTwilightThread = nil
- end)
- else
- if autoBuyTwilightThread then
- task.cancel(autoBuyTwilightThread)
- autoBuyTwilightThread = nil
- end
- end
- return isAutoBuyTwilightEnabled
- end
- -- AUTO-BUY SEED FUNCTION
- function Auto_BuySeed()
- isAutoBuySeedEnabled = not isAutoBuySeedEnabled
- if isAutoBuySeedEnabled then
- autoBuySeedThread = spawn(function()
- while isAutoBuySeedEnabled do
- pcall(function()
- -- Get seed data and stock info
- local DataService = require(ReplicatedStorage.Modules.DataService)
- local SeedData = require(ReplicatedStorage.Data.SeedData)
- local playerData = DataService:GetData()
- if playerData and playerData.SeedStock and playerData.SeedStock.Stocks then
- -- Check each seed in our buy list
- for seedName, shouldBuy in pairs(Buy_Seeds) do
- if shouldBuy then
- -- Verify the seed exists in SeedData and is displayed in shop
- local seedInfo = SeedData[seedName]
- if seedInfo and seedInfo.DisplayInShop then
- -- Keep buying until stock depleted
- while isAutoBuySeedEnabled do
- -- Get fresh data to check current stock
- playerData = DataService:GetData()
- local stockInfo = playerData.SeedStock.Stocks[seedName]
- if stockInfo and stockInfo.Stock > 0 then
- -- Buy the seed
- ReplicatedStorage.GameEvents.BuySeedStock:FireServer(seedName)
- -- Short wait to allow server to process
- task.wait(0.1)
- else
- -- No more stock for this seed, move to next
- break
- end
- end
- end
- end
- end
- end
- end)
- -- Check every 5 seconds for restocked seeds
- task.wait(5)
- end
- autoBuySeedThread = nil
- end)
- else
- autoBuySeedThread = nil
- end
- return isAutoBuySeedEnabled
- end
- function Auto_Plant()
- -- First check if we already know there's a special plant
- if hasSpecialPlant then
- return false
- end
- -- Check again for special plants
- if CheckForSpecialPlants() then
- return false
- end
- isAutoPlantEnabled = not isAutoPlantEnabled
- if isAutoPlantEnabled then
- -- Immediately check if we're already at max capacity before starting
- local playerPlot = GetFarm(player)
- local currentPlantCount = 0
- if playerPlot and playerPlot:FindFirstChild("Important") and
- playerPlot.Important:FindFirstChild("Plants_Physical") then
- currentPlantCount = #playerPlot.Important.Plants_Physical:GetChildren()
- end
- -- Don't start if we're at capacity
- if currentPlantCount >= 50 then
- isAutoPlantEnabled = false
- hasSpecialPlant = true
- return false
- end
- autoPlantThread = spawn(function()
- while isAutoPlantEnabled do
- pcall(function()
- local DataService = require(ReplicatedStorage.Modules.DataService)
- local playerData = DataService:GetData()
- if playerData and playerData.InventoryData then
- -- Find the player's plot
- local playerPlot = GetFarm(player)
- if not playerPlot then return end
- -- Check for special plants
- if CheckForSpecialPlants() then
- isAutoPlantEnabled = false
- if autoPlantThread then
- task.cancel(autoPlantThread)
- autoPlantThread = nil
- end
- return
- end
- -- Check how many plants we already have
- if playerPlot:FindFirstChild("Important") and
- playerPlot.Important:FindFirstChild("Plants_Physical") then
- currentPlantCount = #playerPlot.Important.Plants_Physical:GetChildren()
- end
- -- Set a safety margin - stop at 50 to prevent accidental overflow
- if currentPlantCount >= 50 then
- -- Turn off auto-plant functionality
- isAutoPlantEnabled = false
- if autoPlantThread then
- task.cancel(autoPlantThread)
- autoPlantThread = nil
- end
- return
- end
- -- Find all Can_Plant parts
- local plantSpots = {}
- local allCanPlantParts = {}
- for _, obj in pairs(playerPlot:GetDescendants()) do
- if obj.Name == "Can_Plant" and obj:IsA("BasePart") then
- table.insert(allCanPlantParts, obj)
- end
- end
- -- Only use the second Can_Plant or the last one if there aren't at least 2
- if #allCanPlantParts >= 2 then
- plantSpots = {allCanPlantParts[2]} -- Use only the second Can_Plant
- else
- plantSpots = {allCanPlantParts[#allCanPlantParts]} -- Use the last one if not enough
- end
- if #plantSpots == 0 then return end
- -- Find seeds in inventory
- local seedsToPlant = {}
- for uuid, itemData in pairs(playerData.InventoryData) do
- if itemData.ItemType == "Seed" and itemData.ItemData then
- local seedName = itemData.ItemData.ItemName
- local quantity = itemData.ItemData.Quantity or 0
- if Plant_Seeds[seedName] and quantity > 0 then
- table.insert(seedsToPlant, {
- uuid = uuid,
- name = seedName,
- quantity = quantity
- })
- end
- end
- end
- -- If we have seeds, try to plant them
- if #seedsToPlant > 0 then
- for _, seedInfo in pairs(seedsToPlant) do
- if seedInfo.quantity > 0 then
- -- Check plant count again before each seed type
- if playerPlot:FindFirstChild("Important") and
- playerPlot.Important:FindFirstChild("Plants_Physical") then
- -- Check for special plants again
- if CheckForSpecialPlants() then
- isAutoPlantEnabled = false
- if autoPlantThread then
- task.cancel(autoPlantThread)
- autoPlantThread = nil
- end
- return
- end
- currentPlantCount = #playerPlot.Important.Plants_Physical:GetChildren()
- if currentPlantCount >= 50 then
- isAutoPlantEnabled = false
- if autoPlantThread then
- task.cancel(autoPlantThread)
- autoPlantThread = nil
- end
- return
- end
- end
- -- Find tool by name pattern instead of UUID
- local seedTool = nil
- for _, tool in ipairs(player.Backpack:GetChildren()) do
- -- Only consider tools tagged as Seed
- if tool:GetAttribute("ItemType") == "Seed" then
- -- Match by the Seed attribute
- if tool:GetAttribute("Seed") == seedInfo.name then
- seedTool = tool
- break
- end
- -- Fallback: tool name contains seed name (case-insensitive)
- if tool.Name:lower():find(seedInfo.name:lower()) then
- seedTool = tool
- break
- end
- end
- end
- if seedTool then
- -- Equip the seed
- seedTool.Parent = player.Character
- task.wait(0.5)
- -- Calculate how many more plants we can place (with safety margin)
- local remainingSlots = 50 - currentPlantCount
- -- Use each Can_Plant position with offset
- for i, spot in ipairs(plantSpots) do
- -- Stop if we hit near the limit
- if currentPlantCount >= 50 or remainingSlots <= 0 then
- -- Turn off auto-plant functionality
- isAutoPlantEnabled = false
- if autoPlantThread then
- task.cancel(autoPlantThread)
- autoPlantThread = nil
- end
- break
- end
- -- Stop if we run out of seeds
- if seedInfo.quantity <= 0 then
- break
- end
- -- Create planting position with offset
- local plantPosition = Vector3.new(
- spot.Position.X,
- spot.Position.Y,
- spot.Position.Z + 7
- )
- -- Plant the seed
- ReplicatedStorage.GameEvents.Plant_RE:FireServer(plantPosition, seedInfo.name)
- -- Short wait between plants
- task.wait(0.1)
- -- Update our counters
- seedInfo.quantity = seedInfo.quantity - 1
- currentPlantCount = currentPlantCount + 1
- remainingSlots = remainingSlots - 1
- -- Recheck plant count every 10 plants as safety measure
- if i % 10 == 0 then
- if playerPlot:FindFirstChild("Important") then
- -- Check for special plants again
- if CheckForSpecialPlants() then
- isAutoPlantEnabled = false
- if autoPlantThread then
- task.cancel(autoPlantThread)
- autoPlantThread = nil
- end
- break
- end
- currentPlantCount = #playerPlot.Important.Plants_Physical:GetChildren()
- remainingSlots = 50 - currentPlantCount
- if currentPlantCount >= 50 then
- isAutoPlantEnabled = false
- if autoPlantThread then
- task.cancel(autoPlantThread)
- autoPlantThread = nil
- end
- break
- end
- end
- end
- end
- -- Unequip when done
- if player.Character:FindFirstChild(seedTool.Name) then
- seedTool.Parent = player.Backpack
- end
- end
- end
- end
- end
- end
- end)
- -- Wait before checking again
- task.wait(1)
- end
- autoPlantThread = nil
- end)
- else
- if autoPlantThread then
- task.cancel(autoPlantThread)
- end
- autoPlantThread = nil
- end
- return isAutoPlantEnabled
- end
- function Auto_Delete_Plant()
- isAutoDeletePlantEnabled = not isAutoDeletePlantEnabled
- -- If we know there are no more plants to delete, don't even start
- if noMorePlantsToDelete and isAutoDeletePlantEnabled then
- isAutoDeletePlantEnabled = false
- return false
- end
- if isAutoDeletePlantEnabled then
- autoDeletePlantThread = spawn(function()
- local Remove_Item = game.ReplicatedStorage.GameEvents:WaitForChild("Remove_Item")
- local player = game.Players.LocalPlayer
- local consecutiveEmptyCycles = 0 -- Counter for consecutive cycles with nothing to delete
- while isAutoDeletePlantEnabled do
- local deletedAny = false
- pcall(function()
- local playerPlot = GetFarm(player)
- if playerPlot
- and playerPlot:FindFirstChild("Important")
- and playerPlot.Important:FindFirstChild("Plants_Physical") then
- -- Equip the shovel if it's not already equipped
- local backpack = player:FindFirstChild("Backpack")
- if backpack
- and not player.Character:FindFirstChild("Shovel [Destroy Plants]") then
- local shovel = backpack:FindFirstChild("Shovel [Destroy Plants]")
- if shovel then
- shovel.Parent = player.Character
- task.wait(0.2)
- end
- end
- -- Loop through all plants in your plot
- for _, plant in ipairs(playerPlot.Important.Plants_Physical:GetChildren()) do
- if Delete_Plants[plant.Name] then
- if plant:GetAttribute("Favorited") then
- -- Skip favorited plants
- else
- -- Find the numbered child (e.g. plant["1"])
- local toDelete
- for _, child in ipairs(plant:GetChildren()) do
- if tonumber(child.Name) then
- toDelete = child
- break
- end
- end
- if toDelete then
- Remove_Item:FireServer(toDelete)
- deletedAny = true
- task.wait(0.2)
- end
- end
- end
- end
- end
- end)
- if not deletedAny then
- -- If nothing was deleted, unequip the shovel
- local char = player.Character
- local backpack = player:FindFirstChild("Backpack")
- if char and backpack then
- local shovel = char:FindFirstChild("Shovel [Destroy Plants]")
- if shovel then
- shovel.Parent = backpack
- end
- end
- -- Increment empty cycle counter
- consecutiveEmptyCycles = consecutiveEmptyCycles + 1
- -- If we've had 3 consecutive empty cycles, set the global flag and turn off the function
- if consecutiveEmptyCycles >= 3 then
- noMorePlantsToDelete = true
- isAutoDeletePlantEnabled = false
- break
- end
- -- Wait 60 seconds before next check
- task.wait(60)
- else
- -- Reset counter and the noMorePlantsToDelete flag if we deleted something
- consecutiveEmptyCycles = 0
- noMorePlantsToDelete = false
- -- Wait 5 seconds before next check
- task.wait(5)
- end
- end
- -- Make sure to unequip the shovel when we're done
- pcall(function()
- local char = player.Character
- local backpack = player:FindFirstChild("Backpack")
- if char and backpack then
- local shovel = char:FindFirstChild("Shovel [Destroy Plants]")
- if shovel then
- shovel.Parent = backpack
- end
- end
- end)
- autoDeletePlantThread = nil
- end)
- else
- -- Turn off and clean up
- if autoDeletePlantThread then
- task.cancel(autoDeletePlantThread)
- end
- -- Make sure to unequip the shovel
- pcall(function()
- local char = player.Character
- local backpack = player:FindFirstChild("Backpack")
- if char and backpack then
- local shovel = char:FindFirstChild("Shovel [Destroy Plants]")
- if shovel then
- shovel.Parent = backpack
- end
- end
- end)
- autoDeletePlantThread = nil
- end
- return isAutoDeletePlantEnabled
- end
- function Auto_Feed_Pet()
- isAutoFeedEnabled = not isAutoFeedEnabled
- if isAutoFeedEnabled then
- autoFeedThread = spawn(function()
- -- Get direct reference to remote
- local petRemote = ReplicatedStorage:WaitForChild("GameEvents"):WaitForChild("ActivePetService")
- local player = Players.LocalPlayer
- while isAutoFeedEnabled do
- local allPetsFullyFed = true
- pcall(function()
- -- Get pet data directly from datastore
- local petData = ActivePetsService:GetPlayerDatastorePetData(player.Name)
- if not petData then return end
- -- Check if we have equipped pets
- if not petData.EquippedPets or #petData.EquippedPets == 0 then return end
- -- Check for pet inventory
- if not petData.PetInventory or not petData.PetInventory.Data then return end
- local petInventory = petData.PetInventory.Data
- -- Get reference to PetList for correct max hunger values
- local PetList = require(ReplicatedStorage.Data.PetRegistry.PetList)
- -- Find hungry pets using the equipped pets list directly
- local hungryPets = {}
- for _, uuid in ipairs(petData.EquippedPets) do
- local pet = petInventory[uuid]
- if pet and pet.PetData then
- local hunger = pet.PetData.Hunger or 0
- local petType = pet.PetType
- -- Get the pet's specific max hunger from PetList
- local maxHunger = (PetList[petType] and PetList[petType].DefaultHunger) or 30000
- -- Only add to hungry list if below 30% of its max hunger
- if hunger < maxHunger * 0.4 then
- allPetsFullyFed = false
- table.insert(hungryPets, {
- uuid = uuid,
- hunger = hunger,
- type = petType,
- name = pet.PetData.Name or "Unknown Pet",
- maxHunger = maxHunger
- })
- end
- end
- end
- -- Force allPetsFullyFed to false if we found any hungry pets
- if #hungryPets > 0 then
- allPetsFullyFed = false
- end
- -- Sort by hunger percentage (lowest first)
- table.sort(hungryPets, function(a, b)
- return (a.hunger / a.maxHunger) < (b.hunger / b.maxHunger)
- end)
- if #hungryPets == 0 then return end
- -- Get all items from inventory that can be used as food
- local backpack = player:FindFirstChild("Backpack")
- local character = player.Character
- if not backpack or not character then return end
- -- Get food items that have "kg" in the name, are under 10kg, and not favorited
- local foodTools = {}
- for _, tool in ipairs(backpack:GetChildren()) do
- if tool:IsA("Tool") then
- local toolName = tool.Name
- -- Skip if favorited
- if tool:GetAttribute("IsFavorite") == true then continue end
- -- Look for items with "kg" in the name (foods)
- if toolName:find("kg") then
- -- Try to extract the weight value
- local weightStr = toolName:match("(%d+%.?%d*)kg")
- local weight = tonumber(weightStr)
- -- Only use items under 20kg
- if weight and weight < 20 then
- table.insert(foodTools, tool)
- end
- end
- end
- end
- if #foodTools == 0 then return end
- -- Feed pets one at a time
- for _, pet in ipairs(hungryPets) do
- -- Feed the pet with up to 3 food items
- for i = 1, math.min(3, #foodTools) do
- local food = foodTools[i]
- -- Unequip any currently equipped tool
- local equipped = character:FindFirstChildOfClass("Tool")
- if equipped then
- equipped.Parent = backpack
- task.wait(0.2)
- end
- -- Equip food
- food.Parent = character
- task.wait(0.3)
- -- Feed the pet
- petRemote:FireServer("Feed", pet.uuid)
- task.wait(0.5)
- -- Check if pet is now fed
- local updatedPetData = ActivePetsService:GetPetData(player.Name, pet.uuid)
- if updatedPetData and updatedPetData.PetData then
- local newHunger = updatedPetData.PetData.Hunger or 0
- if newHunger >= pet.maxHunger * 0.9 then
- break -- Stop feeding this pet if it's now full
- end
- end
- end
- -- Return any equipped tool to backpack
- local equipped = character:FindFirstChildOfClass("Tool")
- if equipped then
- equipped.Parent = backpack
- end
- task.wait(0.5) -- Wait between pets
- end
- end)
- -- Make sure we check if we found hungry pets again before waiting
- if allPetsFullyFed then
- task.wait(30) -- Wait 30 seconds when all pets are fed
- else
- task.wait(5) -- Wait time when pets need feeding
- end
- end
- autoFeedThread = nil
- end)
- else
- if autoFeedThread then
- task.cancel(autoFeedThread)
- end
- autoFeedThread = nil
- end
- return isAutoFeedEnabled
- end
- function Auto_PlaceEgg()
- isAutoPlaceEggEnabled = not isAutoPlaceEggEnabled
- if isAutoPlaceEggEnabled then
- autoPlaceEggThread = spawn(function()
- while isAutoPlaceEggEnabled do
- pcall(function()
- local player = game.Players.LocalPlayer
- local character = player.Character
- if not character then return end
- -- Get player data
- local DataService = require(game.ReplicatedStorage.Modules.DataService)
- local playerData = DataService:GetData()
- if not playerData then return end
- -- Find player plot
- local playerPlot = GetFarm(player)
- if not playerPlot then return end
- -- Find Can_Plant
- local canPlant
- for _, obj in pairs(playerPlot:GetDescendants()) do
- if obj.Name == "Can_Plant" and obj:IsA("BasePart") then
- canPlant = obj
- break -- Use first one found
- end
- end
- if not canPlant then return end
- -- Count existing eggs
- local currentEggCount = 0
- local existingEggs = {}
- for _, obj in pairs(workspace:GetDescendants()) do
- if obj:HasTag("PetEggServer") and obj:GetAttribute("OWNER") == player.Name then
- currentEggCount = currentEggCount + 1
- existingEggs[obj:GetAttribute("OBJECT_UUID")] = obj
- end
- end
- -- Check if we have reached the maximum
- local maxEggSlots = playerData.PetsData.MutableStats.MaxEggsInFarm
- -- Hatch ready eggs first
- for _, eggObj in pairs(existingEggs) do
- if eggObj:GetAttribute("TimeToHatch") and eggObj:GetAttribute("TimeToHatch") <= 0 then
- game.ReplicatedStorage.GameEvents.PetEggService:FireServer("HatchPet", eggObj)
- task.wait(1)
- return -- Only hatch one egg per cycle
- end
- end
- -- Place new eggs if we have room
- if currentEggCount < maxEggSlots then
- -- First unequip any current tool
- if character:FindFirstChildOfClass("Tool") then
- for _, tool in pairs(character:GetChildren()) do
- if tool:IsA("Tool") then
- tool.Parent = player.Backpack
- end
- end
- task.wait(1)
- end
- -- Use the global egg index for detection
- for _, tool in ipairs(player.Backpack:GetChildren()) do
- local isEggTool = false
- -- Primary check: ItemType attribute must be PetEgg
- if tool:GetAttribute("ItemType") == "PetEgg" then
- isEggTool = true
- end
- -- Secondary check: Use the egg index table
- if not isEggTool and eggIndex[tool.Name] then
- isEggTool = true
- end
- -- Explicitly exclude pet tools
- if tool:GetAttribute("ItemType") == "Pet" then
- isEggTool = false
- end
- if isEggTool then
- -- Use more direct equip approach
- tool.Parent = character
- task.wait(1) -- Extended wait after equipping
- -- Double check equip
- if character:FindFirstChild(tool.Name) then
- -- Use a simple position with random offset
- local basePosition = canPlant.Position
- local randX = math.random(-10, 10)
- local randZ = math.random(-10, 10)
- local eggPosition = Vector3.new(
- basePosition.X + randX,
- basePosition.Y,
- basePosition.Z + randZ
- )
- -- Try with both possible remote names to be safe
- local success = pcall(function()
- game.ReplicatedStorage.GameEvents.PetEggService:FireServer("CreateEgg", eggPosition)
- end)
- if not success then
- pcall(function()
- game.ReplicatedStorage.GameEvents.PetEggService:FireServer("PlaceEgg", eggPosition)
- end)
- end
- task.wait(1) -- Extended wait after placement attempt
- -- Return to backpack regardless
- if character:FindFirstChild(tool.Name) then
- tool.Parent = player.Backpack
- end
- return -- Only place one egg per cycle
- end
- end
- end
- end
- end)
- -- Wait between cycles
- task.wait(1)
- end
- end)
- else
- if autoPlaceEggThread then
- task.cancel(autoPlaceEggThread)
- autoPlaceEggThread = nil
- end
- end
- return isAutoPlaceEggEnabled
- end
- -- AUTO-SELL PET FUNCTION
- function Auto_Sell_Pet()
- isAutoSellPetEnabled = not isAutoSellPetEnabled
- if isAutoSellPetEnabled then
- autoSellPetThread = spawn(function()
- local SellPet_RE = ReplicatedStorage.GameEvents.SellPet_RE
- local favoriteRemote = ReplicatedStorage:WaitForChild("GameEvents"):WaitForChild("Favorite_Item")
- -- Counter for cycling through pets
- local currentPetIndex = 1
- while isAutoSellPetEnabled do
- local foundPetToProcess = false
- pcall(function()
- local DataService = require(ReplicatedStorage.Modules.DataService)
- local playerData = DataService:GetData()
- if not playerData or not playerData.PetsData or not playerData.PetsData.PetInventory
- or not playerData.PetsData.PetInventory.Data then
- return
- end
- local petInventoryData = playerData.PetsData.PetInventory.Data
- local backpack = player.Backpack
- local character = player.Character
- if not backpack or not character then return end
- -- First unequip any currently equipped tool
- local equipped = character:FindFirstChildOfClass("Tool")
- if equipped then
- equipped.Parent = backpack
- task.wait(0.2)
- end
- -- Get all pet tools from backpack
- local petTools = {}
- for _, tool in pairs(backpack:GetChildren()) do
- if tool:IsA("Tool") and tool:GetAttribute("ItemType") == "Pet" then
- table.insert(petTools, tool)
- end
- end
- -- If no pet tools found, return
- if #petTools == 0 then
- return
- end
- -- Reset index if it's out of bounds
- if currentPetIndex > #petTools then
- currentPetIndex = 1
- return
- end
- -- Get the current pet to process
- local currentTool = petTools[currentPetIndex]
- local petName = currentTool.Name
- foundPetToProcess = true
- -- Check if this pet is already favorited
- local isFavoritedInAttribute = currentTool:GetAttribute("Favorite") == true
- -- Also check in the data
- local uuid = currentTool:GetAttribute("ITEM_UUID")
- local isFavoritedInData = false
- if uuid and petInventoryData[uuid] and petInventoryData[uuid].PetData then
- isFavoritedInData = petInventoryData[uuid].PetData.IsFavorite == true
- end
- -- If it's already favorited in either place, skip processing
- if isFavoritedInAttribute or isFavoritedInData then
- currentPetIndex = currentPetIndex + 1
- return
- end
- -- Extract pet type from name (before first bracket)
- local petType = petName:match("^([^%[]+)")
- if petType then petType = petType:gsub("%s+$", "") end
- -- Extract weight from name
- local petWeight = tonumber(petName:match("(%d+%.?%d*)%s*KG")) or 0
- -- Extract age from name
- local age = tonumber(petName:match("Age%s+(%d+)")) or 1
- -- Check if this pet should be sold based on type and weight
- local shouldSell = false
- if Sell_Pets[petType] == true then
- shouldSell = petWeight <= MAX_PET_KG and age < 5
- end
- if shouldSell then
- -- Equip and sell
- currentTool.Parent = character
- task.wait(0.5)
- SellPet_RE:FireServer(currentTool)
- task.wait(0.5)
- -- Return to backpack if needed
- if character:FindFirstChild(currentTool.Name) then
- currentTool.Parent = backpack
- end
- else
- -- Only favorite if not already favorited
- favoriteRemote:FireServer(currentTool)
- task.wait(0.5)
- end
- -- Increment the pet index for next time
- currentPetIndex = currentPetIndex + 1
- end)
- -- If no pets were found to process, wait longer
- if not foundPetToProcess then
- task.wait(10)
- currentPetIndex = 1 -- Reset index after waiting
- else
- task.wait(1)
- end
- end
- autoSellPetThread = nil
- end)
- else
- if autoSellPetThread then
- task.cancel(autoSellPetThread)
- end
- autoSellPetThread = nil
- end
- return isAutoSellPetEnabled
- end
- function Auto_Submit_Honey()
- isAutoSubmitHoneyEnabled = not isAutoSubmitHoneyEnabled
- if isAutoSubmitHoneyEnabled then
- autoSubmitHoneyThread = spawn(function()
- while isAutoSubmitHoneyEnabled do
- pcall(function()
- -- Get player data
- local DataService = require(ReplicatedStorage.Modules.DataService)
- local playerData = DataService:GetData()
- if not playerData then return end
- -- Check machine state
- local machineState = "empty"
- if playerData.HoneyMachine then
- if playerData.HoneyMachine.IsRunning == true and playerData.HoneyMachine.TimeLeft and playerData.HoneyMachine.TimeLeft > 0 then
- machineState = "processing"
- elseif playerData.HoneyMachine.HoneyStored and playerData.HoneyMachine.HoneyStored > 0 then
- machineState = "readyToCollect"
- end
- end
- -- Handle each machine state
- if machineState == "processing" then
- -- Machine is processing, just wait
- task.wait(10)
- return
- elseif machineState == "readyToCollect" then
- -- Machine has honey to collect, just fire the remote
- local honeyMachineRemote = ReplicatedStorage:WaitForChild("GameEvents"):WaitForChild("HoneyMachineService_RE")
- honeyMachineRemote:FireServer("MachineInteract")
- task.wait(1)
- return
- elseif machineState == "empty" and playerData.InventoryData then
- -- Machine is empty, try to find a pollinated fruit to submit
- -- Find pollinated fruits in inventory
- local pollinatedFruit = nil
- for uuid, itemData in pairs(playerData.InventoryData) do
- if itemData.ItemType == "Holdable" and itemData.ItemData then
- -- Check if item has the Pollinated mutation and is NOT favorited
- if itemData.ItemData.MutationString and
- itemData.ItemData.MutationString:find("Pollinated") and
- not itemData.ItemData.IsFavorite then
- -- Find the tool in the backpack
- for _, t in pairs(player.Backpack:GetChildren()) do
- if t:IsA("Tool") and t:GetAttribute("ITEM_UUID") == uuid then
- -- Double-check it's not favorited using the tool attribute
- if not t:GetAttribute("Favorite") and
- not t:GetAttribute("IsFavorite") then
- pollinatedFruit = t
- break
- end
- end
- end
- if pollinatedFruit then break end
- end
- end
- end
- -- If we found a pollinated fruit, equip and submit it
- if pollinatedFruit then
- -- Ensure character exists
- local char = player.Character or player.CharacterAdded:Wait()
- if not char then return end
- -- Equip the fruit
- pollinatedFruit.Parent = char
- task.wait(0.3) -- Wait to ensure it equips
- -- Submit the fruit to the honey machine
- local honeyMachineRemote = ReplicatedStorage:WaitForChild("GameEvents"):WaitForChild("HoneyMachineService_RE")
- honeyMachineRemote:FireServer("MachineInteract")
- -- Return tool to backpack
- task.wait(0.5)
- if pollinatedFruit.Parent == char then
- pollinatedFruit.Parent = player.Backpack
- end
- else
- -- No pollinated fruit found, wait
- task.wait(5)
- end
- end
- end)
- task.wait(1) -- Base wait between cycles
- end
- autoSubmitHoneyThread = nil
- end)
- else
- if autoSubmitHoneyThread then
- task.cancel(autoSubmitHoneyThread)
- end
- autoSubmitHoneyThread = nil
- end
- return isAutoSubmitHoneyEnabled
- end
- -- AUTO-BUY HONEY SHOP FUNCTION
- function Auto_BuyHoneyShop()
- isAutoBuyHoneyShopEnabled = not isAutoBuyHoneyShopEnabled
- if isAutoBuyHoneyShopEnabled then
- autoBuyHoneyShopThread = spawn(function()
- while isAutoBuyHoneyShopEnabled do
- pcall(function()
- -- Get player data
- local DataService = require(ReplicatedStorage.Modules.DataService)
- local playerData = DataService:GetData()
- if playerData and playerData.EventShopStock and playerData.EventShopStock.Stocks then
- -- Create a list of items to buy based on priority
- local itemsToBuy = {}
- -- Collect available items
- for itemName, stockData in pairs(playerData.EventShopStock.Stocks) do
- -- For ANY item in stock, if we don't have it in our Buy_HoneyShop table yet, add it
- if Buy_HoneyShop[itemName] == nil then
- Buy_HoneyShop[itemName] = {buy = true, priority = 50} -- Default priority
- end
- -- If it's set to buy and in stock, add to our list
- local itemConfig = Buy_HoneyShop[itemName]
- if itemConfig.buy == true and stockData.Stock > 0 then
- table.insert(itemsToBuy, {
- name = itemName,
- stock = stockData.Stock,
- priority = itemConfig.priority
- })
- end
- end
- -- Sort by priority (lower number = higher priority)
- table.sort(itemsToBuy, function(a, b)
- return a.priority < b.priority
- end)
- -- Buy items in priority order
- for _, item in ipairs(itemsToBuy) do
- -- Try to buy all available stock
- local stockAmount = item.stock
- for i = 1, stockAmount do
- -- Make purchase request
- ReplicatedStorage.GameEvents.BuyEventShopStock:FireServer(item.name)
- -- Wait between purchases
- task.wait(0.5)
- -- Check if purchase was successful
- local updatedData = DataService:GetData()
- if updatedData and updatedData.EventShopStock and
- updatedData.EventShopStock.Stocks[item.name] then
- local newStock = updatedData.EventShopStock.Stocks[item.name].Stock
- if newStock < stockAmount then
- stockAmount = newStock -- Update remaining stock
- if stockAmount == 0 then break end
- else
- task.wait(1)
- break
- end
- end
- end
- end
- end
- end)
- -- Check for honey shop items every 5 seconds
- task.wait(5)
- end
- autoBuyHoneyShopThread = nil
- end)
- else
- if autoBuyHoneyShopThread then
- task.cancel(autoBuyHoneyShopThread)
- autoBuyHoneyShopThread = nil
- end
- end
- return isAutoBuyHoneyShopEnabled
- end
- -- Variables for gift system
- local MIN_FRUIT_VALUE_TO_GIFT = 200000000000 -- 200 billion (default)
- local MAX_FRUIT_VALUE_TO_GIFT = 900000000000 -- 900 billion (default)
- local GIFT_FRUIT_AMOUNT = 1 -- Default number of fruits to gift
- local isAutoGiftEnabled = false
- local autoGiftThread = nil
- local WAIT_FOR_GIFT_ACCEPTANCE = false
- -- Create GUI for fruit gifting
- local fruitGiftGui = Instance.new("ScreenGui")
- fruitGiftGui.Name = "FruitGiftGui"
- fruitGiftGui.ResetOnSpawn = false
- fruitGiftGui.Parent = playerGui
- local giftFrame = Instance.new("Frame")
- giftFrame.Name = "GiftFrame"
- giftFrame.Size = UDim2.new(0, 250, 0, 245)
- giftFrame.Position = UDim2.new(0, 10, 0, 250)
- giftFrame.BackgroundColor3 = Color3.fromRGB(45, 45, 65)
- giftFrame.BackgroundTransparency = 0.1
- giftFrame.BorderSizePixel = 0
- giftFrame.Parent = fruitGiftGui
- giftFrame.ClipsDescendants = true
- -- Corner radius for main frame
- local cornerRadius = Instance.new("UICorner")
- cornerRadius.CornerRadius = UDim.new(0, 8)
- cornerRadius.Parent = giftFrame
- -- Title bar
- local titleBar = Instance.new("Frame")
- titleBar.Name = "TitleBar"
- titleBar.Size = UDim2.new(1, 0, 0, 30)
- titleBar.BackgroundColor3 = Color3.fromRGB(35, 35, 55)
- titleBar.BorderSizePixel = 0
- titleBar.Parent = giftFrame
- -- Corner radius for title bar
- local titleCorner = Instance.new("UICorner")
- titleCorner.CornerRadius = UDim.new(0, 8)
- titleCorner.Parent = titleBar
- -- Title label
- local titleLabel = Instance.new("TextLabel")
- titleLabel.Name = "TitleLabel"
- titleLabel.Size = UDim2.new(1, 0, 1, 0)
- titleLabel.BackgroundTransparency = 1
- titleLabel.Text = "Fruit Gifting"
- titleLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
- titleLabel.Font = Enum.Font.GothamBold
- titleLabel.TextSize = 16
- titleLabel.Parent = titleBar
- -- Gift amount section
- local giftAmountLabel = Instance.new("TextLabel")
- giftAmountLabel.Name = "GiftAmountLabel"
- giftAmountLabel.Size = UDim2.new(0.6, 0, 0, 25)
- giftAmountLabel.Position = UDim2.new(0.05, 0, 0, 40)
- giftAmountLabel.BackgroundTransparency = 1
- giftAmountLabel.Text = "Gift Amount:"
- giftAmountLabel.TextColor3 = Color3.fromRGB(220, 220, 255)
- giftAmountLabel.TextXAlignment = Enum.TextXAlignment.Left
- giftAmountLabel.Font = Enum.Font.Gotham
- giftAmountLabel.TextSize = 14
- giftAmountLabel.Parent = giftFrame
- local giftAmountInput = Instance.new("TextBox")
- giftAmountInput.Name = "GiftAmountInput"
- giftAmountInput.Size = UDim2.new(0.3, 0, 0, 25)
- giftAmountInput.Position = UDim2.new(0.65, 0, 0, 40)
- giftAmountInput.BackgroundColor3 = Color3.fromRGB(60, 60, 85)
- giftAmountInput.BorderSizePixel = 0
- giftAmountInput.Text = tostring(GIFT_FRUIT_AMOUNT)
- giftAmountInput.TextColor3 = Color3.fromRGB(255, 255, 255)
- giftAmountInput.Font = Enum.Font.Gotham
- giftAmountInput.TextSize = 14
- giftAmountInput.Parent = giftFrame
- -- Input box corner radius
- local amountCorner = Instance.new("UICorner")
- amountCorner.CornerRadius = UDim.new(0, 6)
- amountCorner.Parent = giftAmountInput
- -- Min price section
- local minPriceLabel = Instance.new("TextLabel")
- minPriceLabel.Name = "MinPriceLabel"
- minPriceLabel.Size = UDim2.new(0.6, 0, 0, 25)
- minPriceLabel.Position = UDim2.new(0.05, 0, 0, 75)
- minPriceLabel.BackgroundTransparency = 1
- minPriceLabel.Text = "Min Value (B):"
- minPriceLabel.TextColor3 = Color3.fromRGB(220, 220, 255)
- minPriceLabel.TextXAlignment = Enum.TextXAlignment.Left
- minPriceLabel.Font = Enum.Font.Gotham
- minPriceLabel.TextSize = 14
- minPriceLabel.Parent = giftFrame
- local minPriceInput = Instance.new("TextBox")
- minPriceInput.Name = "MinPriceInput"
- minPriceInput.Size = UDim2.new(0.3, 0, 0, 25)
- minPriceInput.Position = UDim2.new(0.65, 0, 0, 75)
- minPriceInput.BackgroundColor3 = Color3.fromRGB(60, 60, 85)
- minPriceInput.BorderSizePixel = 0
- minPriceInput.Text = "200" -- Default 200B
- minPriceInput.TextColor3 = Color3.fromRGB(255, 255, 255)
- minPriceInput.Font = Enum.Font.Gotham
- minPriceInput.TextSize = 14
- minPriceInput.Parent = giftFrame
- -- Input box corner radius
- local minCorner = Instance.new("UICorner")
- minCorner.CornerRadius = UDim.new(0, 6)
- minCorner.Parent = minPriceInput
- -- Max price section
- local maxPriceLabel = Instance.new("TextLabel")
- maxPriceLabel.Name = "MaxPriceLabel"
- maxPriceLabel.Size = UDim2.new(0.6, 0, 0, 25)
- maxPriceLabel.Position = UDim2.new(0.05, 0, 0, 110)
- maxPriceLabel.BackgroundTransparency = 1
- maxPriceLabel.Text = "Max Value (B):"
- maxPriceLabel.TextColor3 = Color3.fromRGB(220, 220, 255)
- maxPriceLabel.TextXAlignment = Enum.TextXAlignment.Left
- maxPriceLabel.Font = Enum.Font.Gotham
- maxPriceLabel.TextSize = 14
- maxPriceLabel.Parent = giftFrame
- local maxPriceInput = Instance.new("TextBox")
- maxPriceInput.Name = "MaxPriceInput"
- maxPriceInput.Size = UDim2.new(0.3, 0, 0, 25)
- maxPriceInput.Position = UDim2.new(0.65, 0, 0, 110)
- maxPriceInput.BackgroundColor3 = Color3.fromRGB(60, 60, 85)
- maxPriceInput.BorderSizePixel = 0
- maxPriceInput.Text = "900" -- Default 900B
- maxPriceInput.TextColor3 = Color3.fromRGB(255, 255, 255)
- maxPriceInput.Font = Enum.Font.Gotham
- maxPriceInput.TextSize = 14
- maxPriceInput.Parent = giftFrame
- -- Input box corner radius
- local maxCorner = Instance.new("UICorner")
- maxCorner.CornerRadius = UDim.new(0, 6)
- maxCorner.Parent = maxPriceInput
- -- Wait for gift acceptance toggle
- local waitAcceptLabel = Instance.new("TextLabel")
- waitAcceptLabel.Name = "WaitAcceptLabel"
- waitAcceptLabel.Size = UDim2.new(0.6, 0, 0, 25)
- waitAcceptLabel.Position = UDim2.new(0.05, 0, 0, 145)
- waitAcceptLabel.BackgroundTransparency = 1
- waitAcceptLabel.Text = "Wait for Accept:"
- waitAcceptLabel.TextColor3 = Color3.fromRGB(220, 220, 255)
- waitAcceptLabel.TextXAlignment = Enum.TextXAlignment.Left
- waitAcceptLabel.Font = Enum.Font.Gotham
- waitAcceptLabel.TextSize = 14
- waitAcceptLabel.Parent = giftFrame
- -- Toggle button for wait for acceptance
- local waitAcceptToggle = Instance.new("TextButton")
- waitAcceptToggle.Name = "WaitAcceptToggle"
- waitAcceptToggle.Size = UDim2.new(0.3, 0, 0, 25)
- waitAcceptToggle.Position = UDim2.new(0.65, 0, 0, 145)
- waitAcceptToggle.BackgroundColor3 = Color3.fromRGB(60, 60, 85)
- waitAcceptToggle.BorderSizePixel = 0
- waitAcceptToggle.Text = "OFF"
- waitAcceptToggle.TextColor3 = Color3.fromRGB(255, 255, 255)
- waitAcceptToggle.Font = Enum.Font.GothamBold
- waitAcceptToggle.TextSize = 14
- waitAcceptToggle.Parent = giftFrame
- -- Toggle button corner radius
- local waitToggleCorner = Instance.new("UICorner")
- waitToggleCorner.CornerRadius = UDim.new(0, 6)
- waitToggleCorner.Parent = waitAcceptToggle
- -- Auto gift toggle section
- local autoGiftLabel = Instance.new("TextLabel")
- autoGiftLabel.Name = "AutoGiftLabel"
- autoGiftLabel.Size = UDim2.new(0.6, 0, 0, 25)
- autoGiftLabel.Position = UDim2.new(0.05, 0, 0, 180)
- autoGiftLabel.BackgroundTransparency = 1
- autoGiftLabel.Text = "Auto Gift:"
- autoGiftLabel.TextColor3 = Color3.fromRGB(220, 220, 255)
- autoGiftLabel.TextXAlignment = Enum.TextXAlignment.Left
- autoGiftLabel.Font = Enum.Font.Gotham
- autoGiftLabel.TextSize = 14
- autoGiftLabel.Parent = giftFrame
- -- Toggle button for auto gift
- local autoGiftToggle = Instance.new("TextButton")
- autoGiftToggle.Name = "AutoGiftToggle"
- autoGiftToggle.Size = UDim2.new(0.3, 0, 0, 25)
- autoGiftToggle.Position = UDim2.new(0.65, 0, 0, 180)
- autoGiftToggle.BackgroundColor3 = Color3.fromRGB(60, 60, 85)
- autoGiftToggle.BorderSizePixel = 0
- autoGiftToggle.Text = "OFF"
- autoGiftToggle.TextColor3 = Color3.fromRGB(255, 255, 255)
- autoGiftToggle.Font = Enum.Font.GothamBold
- autoGiftToggle.TextSize = 14
- autoGiftToggle.Parent = giftFrame
- -- Toggle button corner radius
- local toggleCorner = Instance.new("UICorner")
- toggleCorner.CornerRadius = UDim.new(0, 6)
- toggleCorner.Parent = autoGiftToggle
- -- Buttons row
- local setButton = Instance.new("TextButton")
- setButton.Name = "SetButton"
- setButton.Size = UDim2.new(0.45, 0, 0, 30)
- setButton.Position = UDim2.new(0.05, 0, 0, 215)
- setButton.BackgroundColor3 = Color3.fromRGB(80, 170, 100)
- setButton.BorderSizePixel = 0
- setButton.Text = "Set Values"
- setButton.TextColor3 = Color3.fromRGB(255, 255, 255)
- setButton.Font = Enum.Font.GothamBold
- setButton.TextSize = 14
- setButton.Parent = giftFrame
- -- Button corner radius
- local setCorner = Instance.new("UICorner")
- setCorner.CornerRadius = UDim.new(0, 6)
- setCorner.Parent = setButton
- local giftButton = Instance.new("TextButton")
- giftButton.Name = "GiftButton"
- giftButton.Size = UDim2.new(0.45, 0, 0, 30)
- giftButton.Position = UDim2.new(0.5, 0, 0, 215)
- giftButton.BackgroundColor3 = Color3.fromRGB(130, 80, 170)
- giftButton.BorderSizePixel = 0
- giftButton.Text = "Send Gift"
- giftButton.TextColor3 = Color3.fromRGB(255, 255, 255)
- giftButton.Font = Enum.Font.GothamBold
- giftButton.TextSize = 14
- giftButton.Parent = giftFrame
- -- Button corner radius
- local giftCorner = Instance.new("UICorner")
- giftCorner.CornerRadius = UDim.new(0, 6)
- giftCorner.Parent = giftButton
- -- Make GUI draggable
- local dragging = false
- local dragInput
- local dragStart
- local startPos
- titleBar.InputBegan:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
- dragging = true
- dragStart = input.Position
- startPos = giftFrame.Position
- input.Changed:Connect(function()
- if input.UserInputState == Enum.UserInputState.End then
- dragging = false
- end
- end)
- end
- end)
- titleBar.InputChanged:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then
- dragInput = input
- end
- end)
- game:GetService("UserInputService").InputChanged:Connect(function(input)
- if input == dragInput and dragging then
- local delta = input.Position - dragStart
- giftFrame.Position = UDim2.new(
- startPos.X.Scale,
- startPos.X.Offset + delta.X,
- startPos.Y.Scale,
- startPos.Y.Offset + delta.Y
- )
- end
- end)
- -- Wait for acceptance toggle functionality
- waitAcceptToggle.MouseButton1Click:Connect(function()
- WAIT_FOR_GIFT_ACCEPTANCE = not WAIT_FOR_GIFT_ACCEPTANCE
- if WAIT_FOR_GIFT_ACCEPTANCE then
- waitAcceptToggle.Text = "ON"
- waitAcceptToggle.BackgroundColor3 = Color3.fromRGB(80, 170, 100) -- Green
- else
- waitAcceptToggle.Text = "OFF"
- waitAcceptToggle.BackgroundColor3 = Color3.fromRGB(60, 60, 85) -- Default
- end
- end)
- -- Auto gift toggle functionality
- autoGiftToggle.MouseButton1Click:Connect(function()
- isAutoGiftEnabled = not isAutoGiftEnabled
- if isAutoGiftEnabled then
- autoGiftToggle.Text = "ON"
- autoGiftToggle.BackgroundColor3 = Color3.fromRGB(80, 170, 100) -- Green
- -- Start auto gift thread
- if not autoGiftThread then
- autoGiftThread = spawn(function()
- while isAutoGiftEnabled do
- -- Only gift if the button is not already in "Gifting..." state
- if giftButton.Text == "Send Gift" then
- GiftFruitToNearestPlayer()
- end
- -- Wait until gifting is complete
- while giftButton.Text == "Gifting..." and isAutoGiftEnabled do
- task.wait(1)
- end
- -- Wait between gift attempts
- task.wait(5)
- end
- autoGiftThread = nil
- end)
- end
- else
- autoGiftToggle.Text = "OFF"
- autoGiftToggle.BackgroundColor3 = Color3.fromRGB(60, 60, 85) -- Default
- -- Stop auto gift thread
- if autoGiftThread then
- task.cancel(autoGiftThread)
- autoGiftThread = nil
- end
- end
- end)
- -- Set button functionality
- setButton.MouseButton1Click:Connect(function()
- -- Update Gift Amount value
- local giftAmount = tonumber(giftAmountInput.Text)
- if giftAmount and giftAmount > 0 and giftAmount <= 1000 then
- GIFT_FRUIT_AMOUNT = giftAmount
- else
- giftAmountInput.Text = tostring(GIFT_FRUIT_AMOUNT)
- end
- -- Update Min Price value (convert from billions to actual value)
- local minPriceValue = tonumber(minPriceInput.Text)
- if minPriceValue and minPriceValue > 0 then
- MIN_FRUIT_VALUE_TO_GIFT = minPriceValue * 1e9 -- Convert billions to actual value
- else
- minPriceInput.Text = tostring(MIN_FRUIT_VALUE_TO_GIFT / 1e9)
- end
- -- Update Max Price value (convert from billions to actual value)
- local maxPriceValue = tonumber(maxPriceInput.Text)
- if maxPriceValue and maxPriceValue > minPriceValue then
- MAX_FRUIT_VALUE_TO_GIFT = maxPriceValue * 1e9 -- Convert billions to actual value
- else
- maxPriceInput.Text = tostring(MAX_FRUIT_VALUE_TO_GIFT / 1e9)
- end
- -- Update GUI
- giftAmountInput.Text = tostring(GIFT_FRUIT_AMOUNT)
- minPriceInput.Text = tostring(MIN_FRUIT_VALUE_TO_GIFT / 1e9)
- maxPriceInput.Text = tostring(MAX_FRUIT_VALUE_TO_GIFT / 1e9)
- -- Notification
- print("Values set: Gift Amount = " .. GIFT_FRUIT_AMOUNT ..
- ", Min Price = " .. formatNumber(MIN_FRUIT_VALUE_TO_GIFT) ..
- ", Max Price = " .. formatNumber(MAX_FRUIT_VALUE_TO_GIFT))
- end)
- -- Gift button functionality
- giftButton.MouseButton1Click:Connect(function()
- GiftFruitToNearestPlayer()
- end)
- -- Function to gift fruits to nearest player
- function GiftFruitToNearestPlayer()
- -- Prevent multiple runs
- if giftButton.Text ~= "Send Gift" then return end
- -- Update button state
- giftButton.Text = "Gifting..."
- giftButton.BackgroundColor3 = Color3.fromRGB(100, 50, 130)
- spawn(function()
- pcall(function()
- -- Find the nearest player
- local nearestPlayer = nil
- local shortestDistance = math.huge
- local character = player.Character
- if not character then
- print("Character not found!")
- giftButton.Text = "Send Gift"
- giftButton.BackgroundColor3 = Color3.fromRGB(130, 80, 170)
- return
- end
- local rootPart = character:FindFirstChild("HumanoidRootPart")
- if not rootPart then
- print("HumanoidRootPart not found!")
- giftButton.Text = "Send Gift"
- giftButton.BackgroundColor3 = Color3.fromRGB(130, 80, 170)
- return
- end
- for _, otherPlayer in pairs(Players:GetPlayers()) do
- if otherPlayer ~= player and otherPlayer.Character then
- local otherRootPart = otherPlayer.Character:FindFirstChild("HumanoidRootPart")
- if otherRootPart then
- local distance = (rootPart.Position - otherRootPart.Position).Magnitude
- if distance < shortestDistance then
- shortestDistance = distance
- nearestPlayer = otherPlayer
- end
- end
- end
- end
- if not nearestPlayer then
- print("No players found nearby to gift to!")
- giftButton.Text = "Send Gift"
- giftButton.BackgroundColor3 = Color3.fromRGB(130, 80, 170)
- return
- end
- print("Gifting to nearest player: " .. nearestPlayer.Name)
- -- Get player data
- local DataService = require(ReplicatedStorage.Modules.DataService)
- local playerData = DataService:GetData()
- if not playerData or not playerData.InventoryData then
- print("Player data not found!")
- giftButton.Text = "Send Gift"
- giftButton.BackgroundColor3 = Color3.fromRGB(130, 80, 170)
- return
- end
- -- Find fruits within value range
- local validFruits = {}
- for uuid, itemData in pairs(playerData.InventoryData) do
- if itemData.ItemType == "Holdable" and itemData.ItemData then
- -- Find the tool
- local tool = nil
- for _, t in pairs(player.Backpack:GetChildren()) do
- if t:IsA("Tool") and t:GetAttribute("ITEM_UUID") == uuid then
- tool = t
- break
- end
- end
- -- If tool is found, calculate its value
- if tool and tool:GetAttribute("ItemType") ~= "Pet" then
- -- Calculate the item's value
- local itemValue = CalculatePlantValue(tool)
- -- Add to the list if within value range
- if itemValue >= MIN_FRUIT_VALUE_TO_GIFT and itemValue <= MAX_FRUIT_VALUE_TO_GIFT then
- table.insert(validFruits, {
- tool = tool,
- value = itemValue,
- uuid = uuid,
- isFavorite = itemData.ItemData.IsFavorite or false
- })
- end
- end
- end
- end
- -- Sort by value (highest first)
- table.sort(validFruits, function(a, b)
- return a.value > b.value
- end)
- -- Gift each fruit one by one (make sure they have different UUIDs)
- local giftsToSend = {}
- local uniqueUUIDs = {}
- -- Filter for unique UUIDs
- for _, fruitData in ipairs(validFruits) do
- if not uniqueUUIDs[fruitData.uuid] then
- uniqueUUIDs[fruitData.uuid] = true
- table.insert(giftsToSend, fruitData)
- if #giftsToSend >= GIFT_FRUIT_AMOUNT then
- break
- end
- end
- end
- if #giftsToSend == 0 then
- print("No fruits found within value range to gift!")
- giftButton.Text = "Send Gift"
- giftButton.BackgroundColor3 = Color3.fromRGB(130, 80, 170)
- return
- end
- -- Gift each fruit one by one
- print("Gifting " .. #giftsToSend .. " fruits...")
- local giftsCompleted = 0
- for i, fruitData in ipairs(giftsToSend) do
- -- Unequip any current tool
- for _, tool in pairs(character:GetChildren()) do
- if tool:IsA("Tool") then
- tool.Parent = player.Backpack
- end
- end
- task.wait(0.5)
- -- Equip the fruit
- local favoriteStatus = fruitData.isFavorite and " [⭐]" or ""
- print("Gifting #" .. i .. ": " .. fruitData.tool.Name .. favoriteStatus ..
- " - Value: " .. formatNumber(fruitData.value))
- fruitData.tool.Parent = character
- task.wait(0.5) -- Wait longer after equipping
- -- Find and trigger proximity prompts on target player
- local giftSuccess = false
- if nearestPlayer.Character then
- local targetHRP = nearestPlayer.Character:FindFirstChild("HumanoidRootPart")
- if targetHRP then
- for _, obj in pairs(targetHRP:GetChildren()) do
- if obj:IsA("ProximityPrompt") and obj.Enabled then
- -- Trigger the proximity prompt
- fireproximityprompt(obj)
- -- If waiting for acceptance is enabled, actively wait until item is gone
- if WAIT_FOR_GIFT_ACCEPTANCE then
- local waitStartTime = tick()
- local maxWaitTime = 15 -- Maximum wait time in seconds
- -- Update status in GUI
- giftButton.Text = "Waiting..."
- -- Wait loop - check every 1 second if tool is gone
- while tick() - waitStartTime < maxWaitTime do
- -- Check if tool is gone (gift succeeded)
- if not fruitData.tool:IsDescendantOf(game) then
- print("Successfully gifted: " .. fruitData.tool.Name)
- giftSuccess = true
- giftsCompleted = giftsCompleted + 1
- break
- end
- -- Short wait between checks
- task.wait(1)
- end
- -- Update status back
- giftButton.Text = "Gifting..."
- else
- -- Fixed wait time from the original working code
- task.wait(1)
- -- Check if tool is gone (gift succeeded)
- if not fruitData.tool:IsDescendantOf(game) then
- print("Successfully gifted: " .. fruitData.tool.Name)
- giftSuccess = true
- giftsCompleted = giftsCompleted + 1
- end
- end
- if giftSuccess then break end
- end
- end
- end
- end
- -- Return to backpack if still in character and gift failed
- if not giftSuccess and character:FindFirstChild(fruitData.tool.Name) then
- print("Failed to gift: " .. fruitData.tool.Name)
- fruitData.tool.Parent = player.Backpack
- end
- task.wait(0.3)
- end
- print("Gifting complete! Successfully gifted " .. giftsCompleted ..
- " out of " .. #giftsToSend .. " fruits.")
- end)
- -- Ensure button is reset in case of error
- giftButton.Text = "Send Gift"
- giftButton.BackgroundColor3 = Color3.fromRGB(130, 80, 170)
- end)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement