--[[\ Leaf Farm Pro - Rayfield Edition (Fixed Remote Handling & Safe Loading) ]]-- -- Load Rayfield UI Library local Rayfield = loadstring(game:HttpGet('https://sirius.menu/rayfield'))() -- Services local Players = game:GetService("Players") local ReplicatedStorage = ReplicatedStorage or game:GetService("ReplicatedStorage") local Workspace = game:GetService("Workspace") local UserInputService = game:GetService("UserInputService") local VirtualUser = game:GetService("VirtualUser") local RunService = game:GetService("RunService") local player = Players.LocalPlayer -- Configuration Table local Config = { MaxGrabAttempts = 3, TeleportOffset = Vector3.new(0, 3, 0), SuccessCooldown = 0.3, RetryCooldown = 1.5, EscapeHealthThreshold = 30, EnemyDangerRadius = 35, TracerHeightOffset = Vector3.new(0, 4, 0), } -- State Variables local State = { isRunning = false, isBusy = false, instantPromptsActive = false, espActive = false, emergencyTpActive = false, } local blacklistedLeafModels = {} local promptConnections = {} local activeHighlights = {} local tracerLines = {} -- Safe Remote References Setup local function getGrabRemote() local remotes = ReplicatedStorage:WaitForChild("Remotes", 2) if not remotes then return nil end -- Handles different potential folder structures safely local playerRemotes = remotes:FindFirstChild("PlayerRemotes") or (remotes:FindFirstChild("Remotes") and remotes.Remotes:FindFirstChild("PlayerRemotes")) if playerRemotes then return playerRemotes:FindFirstChild("Grab") end return nil end local grabRemote = getGrabRemote() -- Anti-AFK Setup player.Idled:Connect(function() VirtualUser:CaptureController() VirtualUser:ClickButton2(Vector2.new()) end) -- Helper Functions local function getValidCharacter(p) if p.Character and p.Character.Parent == Workspace then return p.Character end return nil end local function getRootPart(char) if not char then return nil end return char:FindFirstChild("HumanoidRootPart") or char.PrimaryPart end local function isAlly(otherPlayer) if otherPlayer == player then return true end if player.Team and otherPlayer.Team and player.Team == otherPlayer.Team then return true end return false end local function isNearEnemies(targetPos) for _, p in ipairs(Players:GetPlayers()) do if p ~= player and not isAlly(p) then local enemyChar = getValidCharacter(p) local enemyRoot = getRootPart(enemyChar) if enemyRoot then if (enemyRoot.Position - targetPos).Magnitude <= Config.EnemyDangerRadius then return true end end end end return false end -- Emergency Escape Logic local function checkEmergencyEscape(character) if not State.emergencyTpActive then return end local humanoid = character:FindFirstChildOfClass("Humanoid") local hrp = getRootPart(character) if not humanoid or not hrp then return end if humanoid.Health <= Config.EscapeHealthThreshold and humanoid.Health > 0 then for _, p in ipairs(Players:GetPlayers()) do if isAlly(p) and p ~= player then local allyChar = getValidCharacter(p) local allyHrp = getRootPart(allyChar) if allyHrp then local distToAlly = (hrp.Position - allyHrp.Position).Magnitude if distToAlly <= 15 and not isNearEnemies(allyHrp.Position) then return end end end end local farthestAllyHrp = nil local maxDistance = -1 for _, p in ipairs(Players:GetPlayers()) do if isAlly(p) and p ~= player then local allyChar = getValidCharacter(p) local allyHrp = getRootPart(allyChar) if allyHrp then local dist = (hrp.Position - allyHrp.Position).Magnitude if dist > maxDistance then maxDistance = dist farthestAllyHrp = allyHrp end end end end if farthestAllyHrp then hrp.AssemblyLinearVelocity = Vector3.new(0, 0, 0) hrp.CFrame = farthestAllyHrp.CFrame + Config.TeleportOffset task.wait(1) end end end -- Proximity Prompt Handling local function setupEatPrompt(prompt) if not prompt:IsA("ProximityPrompt") or prompt.Name ~= "EatPrompt" then return end if State.instantPromptsActive then prompt.HoldDuration = 0 end local conn = prompt.PromptShown:Connect(function() if State.instantPromptsActive then pcall(function() fireproximityprompt(prompt) end) end end) table.insert(promptConnections, conn) end for _, descendant in ipairs(Workspace:GetDescendants()) do if descendant:IsA("ProximityPrompt") and descendant.Name == "EatPrompt" then setupEatPrompt(descendant) end end Workspace.DescendantAdded:Connect(function(descendant) if descendant:IsA("ProximityPrompt") and descendant.Name == "EatPrompt" then setupEatPrompt(descendant) end end) -- Leaf Farm Routine local function getRandomLeafPart() local consumables = Workspace:FindFirstChild("Consumables") local detritus = consumables and consumables:FindFirstChild("Detritus") if not detritus then return nil end local validLeaves = {} for i = 1, 4 do local leafModelName = "Rotting Leaf " .. i local leafModel = detritus:FindFirstChild(leafModelName) if leafModel then local isBlacklisted = false for _, blacklistedModel in ipairs(blacklistedLeafModels) do if blacklistedModel == leafModel then isBlacklisted = true break end end if not isBlacklisted then local leafPart = leafModel:FindFirstChild(leafModelName) if leafPart and leafPart:IsA("BasePart") then table.insert(validLeaves, {model = leafModel, part = leafPart}) end end end end if #validLeaves == 0 then return nil, nil end local chosen = validLeaves[math.random(1, #validLeaves)] return chosen.part, chosen.model end local function hasGrabWeld(character) if not character then return false end local jaw = character:FindFirstChild("Jaw") if jaw and jaw:FindFirstChild("GrabWeld") then return true end return character:FindFirstChild("GrabWeld", true) ~= nil end local function performGrabSequence() if State.isBusy then return false end State.isBusy = true -- Re-check remote dynamically if it wasn't loaded at start grabRemote = grabRemote or getGrabRemote() local character = getValidCharacter(player) local humanoidRootPart = getRootPart(character) if not humanoidRootPart then State.isBusy = false return false end checkEmergencyEscape(character) if hasGrabWeld(character) then if grabRemote then pcall(function() grabRemote:InvokeServer() end) end task.wait(0.3) end local targetPart, targetModel = getRandomLeafPart() if not targetPart or not targetModel then State.isBusy = false return false end local originalCFrame = humanoidRootPart.CFrame local successGrabbed = false local attempts = 0 repeat attempts = attempts + 1 humanoidRootPart.AssemblyLinearVelocity = Vector3.new(0, 0, 0) humanoidRootPart.AssemblyAngularVelocity = Vector3.new(0, 0, 0) humanoidRootPart.CFrame = targetPart.CFrame + Config.TeleportOffset task.wait(0.2) if grabRemote then pcall(function() grabRemote:InvokeServer(targetPart) end) end task.wait(0.3) humanoidRootPart.AssemblyLinearVelocity = Vector3.new(0, 0, 0) humanoidRootPart.AssemblyAngularVelocity = Vector3.new(0, 0, 0) humanoidRootPart.CFrame = originalCFrame task.wait(0.2) if hasGrabWeld(character) then successGrabbed = true end until successGrabbed or attempts >= Config.MaxGrabAttempts if successGrabbed then if grabRemote then task.wait(0.1) pcall(function() grabRemote:InvokeServer() end) end if targetModel then table.insert(blacklistedLeafModels, targetModel) targetModel.AncestryChanged:Connect(function(_, parent) if not parent then for i, model in ipairs(blacklistedLeafModels) do if model == targetModel then table.remove(blacklistedLeafModels, i) break end end end end) end task.wait(0.2) end State.isBusy = false return successGrabbed end -- ESP Update Loop local function updateESP() for _, p in ipairs(Players:GetPlayers()) do if p ~= player and not isAlly(p) then local char = getValidCharacter(p) if State.espActive and char then local highlight = activeHighlights[p] if not highlight then highlight = Instance.new("Highlight") highlight.Adornee = char highlight.FillColor = Color3.fromRGB(255, 50, 50) highlight.OutlineColor = Color3.fromRGB(255, 255, 255) highlight.FillTransparency = 0.5 highlight.Parent = char activeHighlights[p] = highlight end local rootPart = getRootPart(char) local myChar = getValidCharacter(player) local myRoot = getRootPart(myChar) if rootPart and myRoot then local tracer = tracerLines[p] if not tracer then tracer = Instance.new("Part") tracer.Anchored = true tracer.CanCollide = false tracer.Material = Enum.Material.Neon tracer.Color = Color3.fromRGB(255, 50, 50) tracer.Size = Vector3.new(0.1, 0.1, 1) tracer.Parent = Workspace tracerLines[p] = tracer end local p1 = myRoot.Position + Config.TracerHeightOffset local p2 = rootPart.Position + Config.TracerHeightOffset local distance = (p1 - p2).Magnitude tracer.Size = Vector3.new(0.08, 0.08, distance) tracer.CFrame = CFrame.new(p1, p2) * CFrame.new(0, 0, -distance / 2) tracer.Transparency = 0 else if tracerLines[p] then tracerLines[p].Transparency = 1 end end else if activeHighlights[p] then activeHighlights[p]:Destroy() activeHighlights[p] = nil end if tracerLines[p] then tracerLines[p]:Destroy() tracerLines[p] = nil end end else if activeHighlights[p] then activeHighlights[p]:Destroy() activeHighlights[p] = nil end if tracerLines[p] then tracerLines[p]:Destroy() tracerLines[p] = nil end end end end RunService.RenderStepped:Connect(updateESP) -- Continuous background health checker for Emergency TP task.spawn(function() while true do task.wait(0.5) if State.emergencyTpActive then local character = getValidCharacter(player) if character then checkEmergencyEscape(character) end end end end) -- Rayfield Window and Tabs Setup local Window = Rayfield:CreateWindow({ Name = "Leaf Farm Pro - Termite Edition", LoadingTitle = "Leaf Farm Pro", LoadingSubtitle = "by Rayfield", ConfigurationSaving = { Enabled = false, }, KeySystem = false, }) local MainTab = Window:CreateTab("Main", "home") local VisualsTab = Window:CreateTab("Visuals", "eye") local MiscTab = Window:CreateTab("Misc", "list") -- Main Tab Content MainTab:CreateSection("Leaf Farming") MainTab:CreateButton({ Name = "Grab Once", Callback = function() if State.isRunning then return end task.spawn(performGrabSequence) end, }) MainTab:CreateToggle({ Name = "Auto Leaf Farm", CurrentValue = false, Flag = "AutoFarmToggle", Callback = function(Value) State.isRunning = Value task.spawn(function() while State.isRunning do local success = performGrabSequence() task.wait(success and Config.SuccessCooldown or Config.RetryCooldown) end end) end, }) MainTab:CreateSection("Safety & Prompts") MainTab:CreateToggle({ Name = "Instant Eat Prompts", CurrentValue = false, Flag = "InstantPromptsToggle", Callback = function(Value) State.instantPromptsActive = Value for _, descendant in ipairs(Workspace:GetDescendants()) do if descendant:IsA("ProximityPrompt") and descendant.Name == "EatPrompt" then descendant.HoldDuration = State.instantPromptsActive and 0 or 1 end end end, }) MainTab:CreateToggle({ Name = "Emergency TP (HP <= 30)", CurrentValue = false, Flag = "EmergencyTpToggle", Callback = function(Value) State.emergencyTpActive = Value end, }) -- Visuals Tab Content VisualsTab:CreateSection("ESP Settings") VisualsTab:CreateToggle({ Name = "Player ESP & Elevated Tracers", CurrentValue = false, Flag = "EspToggle", Callback = function(Value) State.espActive = Value if not State.espActive then for _, highlight in pairs(activeHighlights) do highlight:Destroy() end activeHighlights = {} for _, tracer in pairs(tracerLines) do tracer:Destroy() end tracerLines = {} end end, }) -- Misc Tab Content MiscTab:CreateSection("External Utility Scripts") MiscTab:CreateButton({ Name = "Execute Dex Explorer", Callback = function() pcall(function() loadstring(game:HttpGet("https://raw.githubusercontent.com/peyton2465/Dex/master/out.lua"))() end) end, }) MiscTab:CreateButton({ Name = "Execute Infinite Yield", Callback = function() pcall(function() loadstring(game:HttpGet('https://raw.githubusercontent.com/EdgeIY/infiniteyield/master/source'))() end) end, }) MiscTab:CreateButton({ Name = "Execute Universal Invisible (Punisher)", Callback = function() pcall(function() loadstring(game:HttpGet("https://rawscripts.net/raw/Universal-Script-Universal-Invisible-by-PUNISHER-116208"))() end) end, }) Rayfield:LoadConfiguration()