humarb

Test3

Aug 17th, 2025 (edited)
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.94 KB | None | 0 0
  1. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  2. local Players = game:GetService("Players")
  3.  
  4. local LocalPlayer = Players.LocalPlayer
  5.  
  6. local DataStream = ReplicatedStorage.GameEvents.DataStream
  7. -- local WeatherEventStarted = ReplicatedStorage.GameEvents.WeatherEventStarted
  8.  
  9. local BuySeed = ReplicatedStorage.GameEvents.BuySeedStock
  10. local BuyGear = ReplicatedStorage.GameEvents.BuyGearStock
  11. local BuyEgg = ReplicatedStorage.GameEvents.BuyPetEgg
  12.  
  13. local BuyEvent = ReplicatedStorage.GameEvents.BuyEventShopStock
  14.  
  15. print("START")
  16.  
  17. local thingToBuy = {
  18. "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"
  19. }
  20.  
  21. local config = {
  22. ['ROOT/EventShopStock/Stocks'] = "Event Stock",
  23. ['ROOT/EventShopRestock/Stocks'] = "Event Restock",
  24. ["ROOT/SeedStocks/Tier 1/Stocks"] = "Seed Stock",
  25. ["ROOT/GearStock/Stocks"] = "Gear Stock",
  26. ["ROOT/PetEggStock/Stocks"] = "PetEgg Stock"
  27. }
  28.  
  29. --["ROOT/GearStock/Gear"] = "Gear What",
  30.  
  31. local function stringInArray(str, arr)
  32. for _, v in ipairs(arr) do
  33. if v == str then
  34. return true
  35. end
  36. end
  37. return false
  38. end
  39.  
  40. local function dump(o)
  41. if type(o) == 'table' then
  42. local s = '{ '
  43. for k,v in pairs(o) do
  44. if type(k) ~= 'number' then k = '"'..k..'"' end
  45. s = s .. '['..k..'] = ' .. dump(v) .. ','
  46. end
  47. return s .. '} '
  48. else
  49. return tostring(o)
  50. end
  51. end
  52.  
  53. local function BuyThing(Title: string, StockData, arrayBuy)
  54. for Num, Data in pairs(StockData) do
  55. local i = 0
  56. for i = 1, Data.Amount, 1 do
  57. --if not stringInArray(Data.Name, arrayBuy) then return end
  58. if Title == "Seed Stock" then
  59. local seedArray = {"Tier 1", Data.Name}
  60. BuySeed:FireServer(unpack(seedArray))
  61. local Remember = ReplicatedStorage.GameEvents.SaveSlotService:WaitForChild("RememberUnlockage")
  62. Remember:FireServer()
  63. task.wait(2)
  64.  
  65. print("Bought", Data.Name, Data.Amount)
  66. elseif Title == "Gear Stock" then
  67. BuyGear:FireServer(Data.Name)
  68. local Remember = ReplicatedStorage.GameEvents.SaveSlotService:WaitForChild("RememberUnlockage")
  69. Remember:FireServer()
  70. task.wait(2)
  71.  
  72. print("Bought", Data.Name, Data.Amount)
  73. elseif Title == "PetEgg Stock" then
  74. BuyEgg:FireServer(Data.Name)
  75. local Remember = ReplicatedStorage.GameEvents.SaveSlotService:WaitForChild("RememberUnlockage")
  76. Remember:FireServer()
  77. task.wait(2)
  78.  
  79. print("Bought", Data.Name, Data.Amount)
  80. elseif Title == "Event Stock" then
  81. BuyEvent:FireServer(Data.Name)
  82. local Remember = ReplicatedStorage.GameEvents.SaveSlotService:WaitForChild("RememberUnlockage")
  83. Remember:FireServer()
  84. task.wait(2)
  85.  
  86. print("Bought", Data.Name, Data.Amount)
  87. end
  88. end
  89. end
  90. end
  91.  
  92. local function GetDataPacket(Data, Target: string)
  93. for _, Packet in Data do
  94. local Name = Packet[1]
  95. local Content = Packet[2]
  96. --print(Name)
  97.  
  98. if Name == Target then
  99. return Content
  100. end
  101. end
  102.  
  103. return
  104. end
  105.  
  106. local function MakeStockData(Stock: table)
  107. local StockData = {}
  108. for StockName, Data in Stock do
  109. local StockAmount = tonumber(Data.Stock)
  110. local EggName = Data.EggName
  111.  
  112. StockName = EggName or StockName
  113. --print(StockName, StockAmount)
  114.  
  115. local tableData = {
  116. Name = StockName,
  117. Amount = StockAmount
  118. }
  119.  
  120. table.insert(StockData, tableData)
  121. end
  122.  
  123. --print("stockData", dump(StockData))
  124. return StockData
  125. end
  126.  
  127. print("START STREAM")
  128.  
  129. local stream = DataStream.OnClientEvent:Connect(function(Type: string, Profile: string, Data: table)
  130. if Type ~= "UpdateData" then return end
  131. if not Profile:find(LocalPlayer.Name) then return end
  132.  
  133. for Packet, Title in pairs(config) do
  134. local Stock = GetDataPacket(Data, Packet)
  135.  
  136. if Stock then
  137. print(Title)
  138. local StockData = MakeStockData(Stock)
  139.  
  140. BuyThing(Title, StockData, thingToBuy)
  141. end
  142. end
  143. end)
  144.  
  145. -- UI
  146. local gui = Instance.new("ScreenGui", LocalPlayer:WaitForChild("PlayerGui"))
  147. gui.Name = "AutoFarmGUI"
  148.  
  149. local frame = Instance.new("Frame", gui)
  150. frame.Size = UDim2.new(0, 120, 0, 50)
  151. frame.Position = UDim2.new(0, 10, 0.5, 10)
  152. frame.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
  153. frame.BorderSizePixel = 0
  154. frame.BackgroundTransparency = 0.2
  155.  
  156. local endBtn = Instance.new("TextButton", frame)
  157. endBtn.Size = UDim2.new(1, -10, 0.9, -5)
  158. endBtn.Position = UDim2.new(0, 5, 0, 5)
  159. endBtn.Text = "End Script"
  160. endBtn.BackgroundColor3 = Color3.fromRGB(200, 100, 100)
  161.  
  162. endBtn.MouseButton1Click:Connect(function()
  163. stream:Disconnect()
  164. stream = nil
  165. gui:Destroy()
  166. end)
Advertisement
Add Comment
Please, Sign In to add comment