Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Configuration
- _G.Field = "Grape Field"
- _G.emptybackpack = 98
- _G.emptyeveryminutes = 10
- _G.minimumemptyminutes = 2
- -- Services
- local player = game:GetService("Players").LocalPlayer
- local workspace = game:GetService("Workspace")
- local debris = workspace:WaitForChild("Debris")
- local replStorage = game:GetService("ReplicatedStorage")
- local TweenService = game:GetService("TweenService")
- print("--- Script Started: Auto-Reconnect Enabled ---")
- local lastHiveTrip = tick()
- local lastFieldTrip = tick()
- local isEmptying = false
- local tweenInfo = TweenInfo.new(0.05, Enum.EasingStyle.Linear)
- -- Function to handle teleporting safely
- local function tweenTeleport(rootPart, targetCFrame)
- if not rootPart or not targetCFrame then return end
- local tween = TweenService:Create(rootPart, tweenInfo, {CFrame = targetCFrame})
- tween:Play()
- tween.Completed:Wait()
- end
- local function claimHive()
- if player.Hive.Value == "" or player.Hive.Value == nil then
- for _, h in pairs(workspace.Hives:GetChildren()) do
- if h:FindFirstChild("Claimed") and h.Claimed.Value == false then
- replStorage:WaitForChild("Remotes"):WaitForChild("ClaimHive"):FireServer(h)
- task.wait(0.5)
- break
- end
- end
- end
- end
- local function useHammer(character)
- local hammer = character:FindFirstChild("Hammer")
- if hammer and hammer:FindFirstChild("ToolRemote") then
- hammer.ToolRemote:FireServer()
- end
- end
- task.spawn(function()
- while task.wait(0.1) do
- -- REFRESH CHARACTER DATA EVERY LOOP
- local character = player.Character
- if not character then continue end
- local rootPart = character:FindFirstChild("HumanoidRootPart")
- local humanoid = character:FindFirstChild("Humanoid")
- -- Don't run logic if we are dead or missing parts
- if not rootPart or not humanoid or humanoid.Health <= 0 then continue end
- claimHive()
- useHammer(character)
- local currentPollen = player.Pollen.Value
- local maxCap = player.Cap.Value
- local pollenPercent = (currentPollen / maxCap) * 100
- local timeSinceLastHive = (tick() - lastHiveTrip) / 60
- local timeSinceAtHive = (tick() - lastFieldTrip) / 60
- -- 1. TRIGGER HIVE
- if not isEmptying and (pollenPercent >= _G.emptybackpack or timeSinceLastHive >= _G.emptyeveryminutes) then
- isEmptying = true
- lastFieldTrip = tick()
- end
- -- 2. EXIT HIVE
- if isEmptying and (currentPollen <= 0 or timeSinceAtHive >= _G.minimumemptyminutes) then
- isEmptying = false
- lastHiveTrip = tick()
- end
- -- 3. ACTIONS
- if isEmptying then
- local myHiveName = player.Hive.Value
- local myHive = workspace.Hives:FindFirstChild(tostring(myHiveName))
- if myHive then
- rootPart.CFrame = myHive.Platform.Top.CFrame + Vector3.new(0, 3, 0)
- if not player.MakingHoney.Value then
- replStorage:WaitForChild("Remotes"):WaitForChild("MakeHoney"):FireServer(true)
- end
- end
- else
- -- FIELD LOGIC
- local fieldFolder = workspace.Fields:FindFirstChild(_G.Field)
- if fieldFolder then
- local fieldPart = fieldFolder:FindFirstChildWhichIsA("BasePart", true)
- if fieldPart then
- local distance = (rootPart.Position - fieldPart.Position).Magnitude
- if distance > 50 then
- rootPart.CFrame = fieldPart.CFrame + Vector3.new(0, 5, 0)
- task.wait(0.5)
- else
- -- TOKEN COLLECTION
- local myTokens = {}
- for _, v in pairs(debris.Tokens:GetChildren()) do
- -- Change this name if your token name changes
- if v.Name == "JuanMez012" then table.insert(myTokens, v) end
- end
- if #myTokens > 0 then
- local targetToken = myTokens[1]
- if targetToken and targetToken.Parent then
- tweenTeleport(rootPart, targetToken.CFrame)
- task.wait(0.1)
- end
- else
- -- RANDOM MOVEMENT
- local children = fieldFolder:GetChildren()
- local randomTarget = children[math.random(1, #children)]
- if randomTarget:IsA("BasePart") then
- humanoid:MoveTo(randomTarget.Position)
- end
- end
- end
- end
- end
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment