Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local Players = game:GetService("Players")
- local LocalPlayer = Players.LocalPlayer
- local DataStream = ReplicatedStorage.GameEvents.DataStream
- -- local WeatherEventStarted = ReplicatedStorage.GameEvents.WeatherEventStarted
- local BuySeed = ReplicatedStorage.GameEvents.BuySeedStock
- local BuyGear = ReplicatedStorage.GameEvents.BuyGearStock
- local BuyEgg = ReplicatedStorage.GameEvents.BuyPetEgg
- local BuyEvent = ReplicatedStorage.GameEvents.BuyEventShopStock
- print("START")
- local thingToBuy = {
- "Watering Can", "Strawberry", "Blueberry", "Beanstalk", "Ember Lily", "Sugar Apple", "Burning Bud", "Giant Pinecone", "Elder Strawberry", "Romanesco", "Magnifying Glass", "Basic Sprinkler", "Advanced Sprinkler", "Godly Sprinkler", "Master Sprinkler", "Grandmaster Sprinkler", "Levelup Lollipop", "Medium Toy", "Medium Treat", "Cleansing Pet Shard", "Uncommon Egg", "Rare Egg", "Legendary Egg", "Mythical Egg", "Bug Egg"
- }
- local config = {
- ['ROOT/EventShopStock/Stocks'] = "Event Stock",
- ['ROOT/EventShopRestock/Stocks'] = "Event Restock",
- ["ROOT/SeedStocks/Tier 1/Stocks"] = "Seed Stock",
- ["ROOT/GearStock/Stocks"] = "Gear Stock",
- ["ROOT/PetEggStock/Stocks"] = "PetEgg Stock"
- }
- --["ROOT/GearStock/Gear"] = "Gear What",
- local function stringInArray(str, arr)
- for _, v in ipairs(arr) do
- if v == str then
- return true
- end
- end
- return false
- end
- local function dump(o)
- if type(o) == 'table' then
- local s = '{ '
- for k,v in pairs(o) do
- if type(k) ~= 'number' then k = '"'..k..'"' end
- s = s .. '['..k..'] = ' .. dump(v) .. ','
- end
- return s .. '} '
- else
- return tostring(o)
- end
- end
- local function BuyThing(Title: string, StockData, arrayBuy)
- for Num, Data in pairs(StockData) do
- local i = 0
- for i = 1, Data.Amount, 1 do
- --if not stringInArray(Data.Name, arrayBuy) then return end
- if Title == "Seed Stock" then
- local seedArray = {"Tier 1", Data.Name}
- BuySeed:FireServer(unpack(seedArray))
- local Remember = ReplicatedStorage.GameEvents.SaveSlotService:WaitForChild("RememberUnlockage")
- Remember:FireServer()
- task.wait(2)
- print("Bought", Data.Name, Data.Amount)
- elseif Title == "Gear Stock" then
- BuyGear:FireServer(Data.Name)
- local Remember = ReplicatedStorage.GameEvents.SaveSlotService:WaitForChild("RememberUnlockage")
- Remember:FireServer()
- task.wait(2)
- print("Bought", Data.Name, Data.Amount)
- elseif Title == "PetEgg Stock" then
- BuyEgg:FireServer(Data.Name)
- local Remember = ReplicatedStorage.GameEvents.SaveSlotService:WaitForChild("RememberUnlockage")
- Remember:FireServer()
- task.wait(2)
- print("Bought", Data.Name, Data.Amount)
- elseif Title == "Event Stock" then
- BuyEvent:FireServer(Data.Name)
- local Remember = ReplicatedStorage.GameEvents.SaveSlotService:WaitForChild("RememberUnlockage")
- Remember:FireServer()
- task.wait(2)
- print("Bought", Data.Name, Data.Amount)
- end
- end
- end
- end
- local function GetDataPacket(Data, Target: string)
- for _, Packet in Data do
- local Name = Packet[1]
- local Content = Packet[2]
- --print(Name)
- if Name == Target then
- return Content
- end
- end
- return
- end
- local function MakeStockData(Stock: table)
- local StockData = {}
- for StockName, Data in Stock do
- local StockAmount = tonumber(Data.Stock)
- local EggName = Data.EggName
- StockName = EggName or StockName
- --print(StockName, StockAmount)
- local tableData = {
- Name = StockName,
- Amount = StockAmount
- }
- table.insert(StockData, tableData)
- end
- --print("stockData", dump(StockData))
- return StockData
- end
- print("START STREAM")
- local stream = DataStream.OnClientEvent:Connect(function(Type: string, Profile: string, Data: table)
- if Type ~= "UpdateData" then return end
- if not Profile:find(LocalPlayer.Name) then return end
- for Packet, Title in pairs(config) do
- local Stock = GetDataPacket(Data, Packet)
- if Stock then
- print(Title)
- local StockData = MakeStockData(Stock)
- BuyThing(Title, StockData, thingToBuy)
- end
- end
- end)
- -- UI
- local gui = Instance.new("ScreenGui", LocalPlayer:WaitForChild("PlayerGui"))
- gui.Name = "AutoFarmGUI"
- local frame = Instance.new("Frame", gui)
- frame.Size = UDim2.new(0, 120, 0, 50)
- frame.Position = UDim2.new(0, 10, 0.5, 10)
- frame.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
- frame.BorderSizePixel = 0
- frame.BackgroundTransparency = 0.2
- local endBtn = Instance.new("TextButton", frame)
- endBtn.Size = UDim2.new(1, -10, 0.9, -5)
- endBtn.Position = UDim2.new(0, 5, 0, 5)
- endBtn.Text = "End Script"
- endBtn.BackgroundColor3 = Color3.fromRGB(200, 100, 100)
- endBtn.MouseButton1Click:Connect(function()
- stream:Disconnect()
- stream = nil
- gui:Destroy()
- end)
Advertisement
Add Comment
Please, Sign In to add comment