local RS = game:GetService("ReplicatedStorage") local seeds = require(RS.Data.SeedData) local gears = require(RS.Data.GearData) local remotetobuytheseeds = RS.GameEvents.BuySeedStock local remotetobuythegear = RS.GameEvents.BuyGearStock local seedshopui = game:GetService("Players").LocalPlayer.PlayerGui.Seed_Shop.Frame.ScrollingFrame local gearshopui = game:GetService("Players").LocalPlayer.PlayerGui.Gear_Shop.Frame.ScrollingFrame local function howmanyseedsarethereinstock(seed) local alltheseeds = seedshopui:GetChildren() if #alltheseeds > 0 then for _, frame in ipairs(alltheseeds) do if frame.Name == seed then if frame:WaitForChild("Main_Frame"):WaitForChild("Stock_Text") then local stock = frame:WaitForChild("Main_Frame"):WaitForChild("Stock_Text").Text local howmanyareinstock = tonumber(stock:match("X(%d+) Stock")) if howmanyareinstock and howmanyareinstock > 0 then return howmanyareinstock else return 0 end end end end end return 0 end local function howmanygearsarethereinstock(gear) local allthegears = gearshopui:GetChildren() if #allthegears > 0 then for _, frame in ipairs(allthegears) do if frame.Name == gear then if frame:WaitForChild("Main_Frame"):WaitForChild("Stock_Text") then local stock = frame:WaitForChild("Main_Frame"):WaitForChild("Stock_Text").Text local howmanypearsareinstock = tonumber(stock:match("X(%d+) Stock")) if howmanypearsareinstock and howmanypearsareinstock > 0 then return howmanypearsareinstock else return 0 end end end end end return 0 end local function buyalltheseedscurrentlyinstock() for nameoftheseed, _ in pairs(seeds) do local numberofseedsinstock = howmanyseedsarethereinstock(nameoftheseed) if numberofseedsinstock > 0 then for i = 1, numberofseedsinstock do remotetobuytheseeds:FireServer(nameoftheseed) task.wait() end end end end local function buyallthegearscurrentlyinstock() for nameofthegear, _ in pairs(gears) do local numberofgearsinstock = howmanygearsarethereinstock(nameofthegear) if numberofgearsinstock > 0 then for i = 1, numberofgearsinstock do remotetobuythegear:FireServer(nameofthegear) task.wait() end end end end buyalltheseedscurrentlyinstock() buyallthegearscurrentlyinstock()