Scripter_RobloxDood

Herb Farm

Aug 28th, 2025 (edited)
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.45 KB | None | 0 0
  1. -- Auto Herb Collector + Auto Pill Crafter GUI
  2. -- Tabs: Herbs | Pills | Info
  3. -- Tracks Spirit Grass + Ginseng counts
  4.  
  5. local player = game.Players.LocalPlayer
  6. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  7. local ScreenGui = Instance.new("ScreenGui")
  8. ScreenGui.Parent = player:WaitForChild("PlayerGui")
  9.  
  10. -- Main Frame
  11. local Frame = Instance.new("Frame", ScreenGui)
  12. Frame.Size = UDim2.new(0, 260, 0, 220)
  13. Frame.Position = UDim2.new(0, 100, 0, 100)
  14. Frame.BackgroundColor3 = Color3.fromRGB(25, 25, 25)
  15. Frame.BorderSizePixel = 0
  16. Instance.new("UICorner", Frame).CornerRadius = UDim.new(0, 8)
  17.  
  18. -- Title
  19. local Title = Instance.new("TextLabel", Frame)
  20. Title.Size = UDim2.new(1, 0, 0, 30)
  21. Title.BackgroundTransparency = 1
  22. Title.Text = "🌿 Auto Herb Collector / Auto Pill Crafter"
  23. Title.Font = Enum.Font.SourceSansBold
  24. Title.TextSize = 18
  25. Title.TextColor3 = Color3.fromRGB(200, 200, 200)
  26.  
  27. -- Tab Frame
  28. local TabFrame = Instance.new("Frame", Frame)
  29. TabFrame.Size = UDim2.new(1, 0, 0, 30)
  30. TabFrame.Position = UDim2.new(0, 0, 0, 30)
  31. TabFrame.BackgroundTransparency = 1
  32. local UIListLayout = Instance.new("UIListLayout", TabFrame)
  33. UIListLayout.FillDirection = Enum.FillDirection.Horizontal
  34. UIListLayout.Padding = UDim.new(0, 5)
  35. UIListLayout.HorizontalAlignment = Enum.HorizontalAlignment.Center
  36.  
  37. -- Create Tab Button
  38. local function createTabButton(text)
  39. local btn = Instance.new("TextButton")
  40. btn.Size = UDim2.new(0, 80, 0, 25)
  41. btn.Text = text
  42. btn.Font = Enum.Font.SourceSansBold
  43. btn.TextSize = 16
  44. btn.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
  45. btn.TextColor3 = Color3.new(1, 1, 1)
  46. btn.BorderSizePixel = 0
  47. Instance.new("UICorner", btn).CornerRadius = UDim.new(0, 6)
  48. btn.Parent = TabFrame
  49. return btn
  50. end
  51.  
  52. local HerbTab = createTabButton("Herbs")
  53. local PillTab = createTabButton("Pills")
  54. local InfoTab = createTabButton("Info")
  55.  
  56. -- Content Frames
  57. local HerbFrame = Instance.new("Frame", Frame)
  58. HerbFrame.Size = UDim2.new(1, 0, 1, -65)
  59. HerbFrame.Position = UDim2.new(0, 0, 0, 65)
  60. HerbFrame.BackgroundTransparency = 1
  61.  
  62. local PillFrame = Instance.new("Frame", Frame)
  63. PillFrame.Size = UDim2.new(1, 0, 1, -65)
  64. PillFrame.Position = UDim2.new(0, 0, 0, 65)
  65. PillFrame.BackgroundTransparency = 1
  66. PillFrame.Visible = false
  67.  
  68. local InfoFrame = Instance.new("Frame", Frame)
  69. InfoFrame.Size = UDim2.new(1, 0, 1, -65)
  70. InfoFrame.Position = UDim2.new(0, 0, 0, 65)
  71. InfoFrame.BackgroundTransparency = 1
  72. InfoFrame.Visible = false
  73.  
  74. -- Create Button
  75. local function createButton(parent, text, color, y)
  76. local btn = Instance.new("TextButton", parent)
  77. btn.Size = UDim2.new(0, 220, 0, 35)
  78. btn.Position = UDim2.new(0, 20, 0, y)
  79. btn.Text = text
  80. btn.Font = Enum.Font.SourceSansBold
  81. btn.TextSize = 16
  82. btn.BackgroundColor3 = color
  83. btn.TextColor3 = Color3.new(1, 1, 1)
  84. btn.BorderSizePixel = 0
  85. Instance.new("UICorner", btn).CornerRadius = UDim.new(0, 6)
  86. return btn
  87. end
  88.  
  89. -- Herb Buttons
  90. local GrassBtn = createButton(HerbFrame, "Toggle Spirit Grass", Color3.fromRGB(70,130,180), 0)
  91. local GinsengBtn = createButton(HerbFrame, "Toggle Ginseng2", Color3.fromRGB(180,130,70), 45)
  92.  
  93. -- Pill Button
  94. local CraftBtn = createButton(PillFrame, "Toggle Auto Craft Pills", Color3.fromRGB(128,0,128), 0)
  95.  
  96. -- Info Labels
  97. local GrassLabel = Instance.new("TextLabel", InfoFrame)
  98. GrassLabel.Size = UDim2.new(0, 220, 0, 25)
  99. GrassLabel.Position = UDim2.new(0, 20, 0, 10)
  100. GrassLabel.BackgroundTransparency = 1
  101. GrassLabel.TextColor3 = Color3.fromRGB(150, 220, 150)
  102. GrassLabel.Font = Enum.Font.SourceSansBold
  103. GrassLabel.TextSize = 16
  104. GrassLabel.Text = "Spirit Grass (100): 0"
  105.  
  106. local GinsengLabel = Instance.new("TextLabel", InfoFrame)
  107. GinsengLabel.Size = UDim2.new(0, 220, 0, 25)
  108. GinsengLabel.Position = UDim2.new(0, 20, 0, 40)
  109. GinsengLabel.BackgroundTransparency = 1
  110. GinsengLabel.TextColor3 = Color3.fromRGB(220, 200, 150)
  111. GinsengLabel.Font = Enum.Font.SourceSansBold
  112. GinsengLabel.TextSize = 16
  113. GinsengLabel.Text = "Ginseng (100): 0"
  114.  
  115. -- Close Button
  116. local CloseBtn = createButton(Frame, "Close GUI", Color3.fromRGB(180,60,60), 180)
  117.  
  118. -- Toggles
  119. getgenv().CollectGrass = false
  120. getgenv().CollectGinseng = false
  121. getgenv().AutoCraft = false
  122.  
  123. -- Collector Loop
  124. task.spawn(function()
  125. while task.wait(0.3) do
  126. if getgenv().CollectGrass then
  127. for _, herb in pairs(workspace.Herbs:GetChildren()) do
  128. if herb.Name == "Spirit Grass" and herb:IsA("Model") then
  129. local target = herb:FindFirstChild("Spirit Grass")
  130. if target then
  131. ReplicatedStorage.Events.CollectHerb:FireServer(target)
  132. end
  133. end
  134. end
  135. end
  136. if getgenv().CollectGinseng then
  137. local ginseng2 = workspace.Herbs:FindFirstChild("Ginseng2")
  138. if ginseng2 and ginseng2:FindFirstChild("Ginseng") then
  139. ReplicatedStorage.Events.CollectHerb:FireServer(ginseng2.Ginseng)
  140. end
  141. end
  142. end
  143. end)
  144.  
  145. -- Auto Craft Loop
  146. task.spawn(function()
  147. while task.wait(1) do
  148. if getgenv().AutoCraft then
  149. local args = {
  150. "Herb_Ginseng_100",
  151. "Herb_Ginseng_100",
  152. "Herb_Spirit Grass_100",
  153. "Herb_Spirit Grass_100",
  154. 25
  155. }
  156. pcall(function()
  157. ReplicatedStorage.Events.CraftPill:FireServer(unpack(args))
  158. end)
  159. end
  160. end
  161. end)
  162.  
  163. -- Replica listeners
  164. local events = ReplicatedStorage:WaitForChild("ReplicaRemoteEvents")
  165. events.Replica_ReplicaSetValue.OnClientEvent:Connect(function(replica, path, value)
  166. local fullPath = table.concat(path, "/")
  167. if fullPath == "Inventory/Herbs/Herb_Ginseng/100" then
  168. GinsengLabel.Text = "Ginseng (100): " .. value
  169. elseif fullPath == "Inventory/Herbs/Herb_Spirit Grass/100" then
  170. GrassLabel.Text = "Spirit Grass (100): " .. value
  171. end
  172. end)
  173. events.Replica_ReplicaSetValues.OnClientEvent:Connect(function(replica, values)
  174. for path, value in pairs(values) do
  175. local fullPath = table.concat(path, "/")
  176. if fullPath == "Inventory/Herbs/Herb_Ginseng/100" then
  177. GinsengLabel.Text = "Ginseng (100): " .. value
  178. elseif fullPath == "Inventory/Herbs/Herb_Spirit Grass/100" then
  179. GrassLabel.Text = "Spirit Grass (100): " .. value
  180. end
  181. end
  182. end)
  183.  
  184. -- Button Logic
  185. GrassBtn.MouseButton1Click:Connect(function()
  186. getgenv().CollectGrass = not getgenv().CollectGrass
  187. GrassBtn.Text = getgenv().CollectGrass and "Grass: ON" or "Grass: OFF"
  188. end)
  189. GinsengBtn.MouseButton1Click:Connect(function()
  190. getgenv().CollectGinseng = not getgenv().CollectGinseng
  191. GinsengBtn.Text = getgenv().CollectGinseng and "Ginseng: ON" or "Ginseng: OFF"
  192. end)
  193. CraftBtn.MouseButton1Click:Connect(function()
  194. getgenv().AutoCraft = not getgenv().AutoCraft
  195. CraftBtn.Text = getgenv().AutoCraft and "Crafting: ON" or "Crafting: OFF"
  196. end)
  197. CloseBtn.MouseButton1Click:Connect(function()
  198. ScreenGui:Destroy()
  199. end)
  200.  
  201. -- Tab Switching
  202. HerbTab.MouseButton1Click:Connect(function()
  203. HerbFrame.Visible = true
  204. PillFrame.Visible = false
  205. InfoFrame.Visible = false
  206. end)
  207. PillTab.MouseButton1Click:Connect(function()
  208. HerbFrame.Visible = false
  209. PillFrame.Visible = true
  210. InfoFrame.Visible = false
  211. end)
  212. InfoTab.MouseButton1Click:Connect(function()
  213. HerbFrame.Visible = false
  214. PillFrame.Visible = false
  215. InfoFrame.Visible = true
  216. end)
  217.  
  218. -- Draggable
  219. local UserInputService = game:GetService("UserInputService")
  220. local dragging, dragInput, dragStart, startPos
  221. Frame.InputBegan:Connect(function(input)
  222. if input.UserInputType == Enum.UserInputType.MouseButton1 then
  223. dragging = true
  224. dragStart = input.Position
  225. startPos = Frame.Position
  226. input.Changed:Connect(function()
  227. if input.UserInputState == Enum.UserInputState.End then
  228. dragging = false
  229. end
  230. end)
  231. end
  232. end)
  233. Frame.InputChanged:Connect(function(input)
  234. if input.UserInputType == Enum.UserInputType.MouseMovement then
  235. dragInput = input
  236. end
  237. end)
  238. UserInputService.InputChanged:Connect(function(input)
  239. if input == dragInput and dragging then
  240. local delta = input.Position - dragStart
  241. Frame.Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X,
  242. startPos.Y.Scale, startPos.Y.Offset + delta.Y)
  243. end
  244. end)
  245.  
  246.  
Advertisement
Add Comment
Please, Sign In to add comment