local Players = game:GetService("Players") local Workspace = game:GetService("Workspace") local TweenService = game:GetService("TweenService") local CoreGui = game:GetService("CoreGui") local UserInputService = game:GetService("UserInputService") local LocalPlayer = Players.LocalPlayer local GuiParent = (gethui and gethui()) or CoreGui local GuiName = "AppleModelFarmGui_Unique" if _G.AppleFarmCleanup then pcall(_G.AppleFarmCleanup) end local OldGui = GuiParent:FindFirstChild(GuiName) if OldGui then OldGui:Destroy() end local AppleFolder = Workspace:FindFirstChild("AutumnApples") local FlySpeed = 215 local MaxRange = 365 local IsFarming = false local CachedModels = {} local CurrentTween = nil local AppleNotFoundShown = false local AppleNotFoundToken = 0 local ScreenGui = Instance.new("ScreenGui") ScreenGui.Name = GuiName ScreenGui.ResetOnSpawn = false ScreenGui.Parent = GuiParent local function getModelPosition(model) if model and model:IsA("Model") then return model:GetPivot().Position end return nil end local AddedConn = nil local RemovingConn = nil local FolderWatchConn = nil local InputConn = nil local function BindAppleFolder(folder) if not folder or AppleFolder == folder and AddedConn then return end AppleFolder = folder CachedModels = {} if AddedConn then AddedConn:Disconnect() end if RemovingConn then RemovingConn:Disconnect() end for _, obj in ipairs(AppleFolder:GetDescendants()) do if obj:IsA("Model") then CachedModels[obj] = true end end AddedConn = AppleFolder.DescendantAdded:Connect(function(obj) if obj:IsA("Model") then CachedModels[obj] = true end end) RemovingConn = AppleFolder.DescendantRemoving:Connect(function(obj) if CachedModels[obj] then CachedModels[obj] = nil end end) end if AppleFolder then BindAppleFolder(AppleFolder) end FolderWatchConn = Workspace.ChildAdded:Connect(function(child) if child.Name == "AutumnApples" then BindAppleFolder(child) end end) local function CleanupAll() IsFarming = false AppleNotFoundToken += 1 AppleNotFoundShown = false if CurrentTween then CurrentTween:Cancel() CurrentTween = nil end if AddedConn then AddedConn:Disconnect() AddedConn = nil end if RemovingConn then RemovingConn:Disconnect() RemovingConn = nil end if FolderWatchConn then FolderWatchConn:Disconnect() FolderWatchConn = nil end if InputConn then InputConn:Disconnect() InputConn = nil end local char = LocalPlayer.Character local hrp = char and char:FindFirstChild("HumanoidRootPart") if hrp then hrp.Velocity = Vector3.new(0, 0, 0) end end _G.AppleFarmCleanup = CleanupAll ScreenGui.Destroying:Connect(CleanupAll) local MainFrame = Instance.new("Frame") MainFrame.Size = UDim2.new(0, 240, 0, 132) MainFrame.Position = UDim2.new(0.5, -120, 0.15, 0) MainFrame.BackgroundColor3 = Color3.fromRGB(30, 30, 35) MainFrame.BorderSizePixel = 0 MainFrame.Active = true MainFrame.Draggable = true MainFrame.Parent = ScreenGui local UICorner = Instance.new("UICorner") UICorner.CornerRadius = UDim.new(0, 8) UICorner.Parent = MainFrame local Title = Instance.new("TextLabel") Title.Size = UDim2.new(1, -65, 0, 32) Title.Position = UDim2.new(0, 10, 0, 0) Title.BackgroundTransparency = 1 Title.Text = "Autumn Apples Farm [Q]" Title.TextColor3 = Color3.fromRGB(255, 255, 255) Title.Font = Enum.Font.GothamBold Title.TextSize = 13 Title.TextXAlignment = Enum.TextXAlignment.Left Title.Parent = MainFrame local MinimizeBtn = Instance.new("TextButton") MinimizeBtn.Size = UDim2.new(0, 24, 0, 24) MinimizeBtn.Position = UDim2.new(1, -56, 0, 4) MinimizeBtn.BackgroundColor3 = Color3.fromRGB(55, 55, 65) MinimizeBtn.Text = "-" MinimizeBtn.TextColor3 = Color3.fromRGB(255, 255, 255) MinimizeBtn.Font = Enum.Font.GothamBold MinimizeBtn.TextSize = 14 MinimizeBtn.Parent = MainFrame local MinCorner = Instance.new("UICorner") MinCorner.CornerRadius = UDim.new(0, 5) MinCorner.Parent = MinimizeBtn local CloseBtn = Instance.new("TextButton") CloseBtn.Size = UDim2.new(0, 24, 0, 24) CloseBtn.Position = UDim2.new(1, -28, 0, 4) CloseBtn.BackgroundColor3 = Color3.fromRGB(200, 50, 50) CloseBtn.Text = "X" CloseBtn.TextColor3 = Color3.fromRGB(255, 255, 255) CloseBtn.Font = Enum.Font.GothamBold CloseBtn.TextSize = 12 CloseBtn.Parent = MainFrame local CloseCorner = Instance.new("UICorner") CloseCorner.CornerRadius = UDim.new(0, 5) CloseCorner.Parent = CloseBtn local StatusLabel = Instance.new("TextLabel") StatusLabel.Size = UDim2.new(0.88, 0, 0, 20) StatusLabel.Position = UDim2.new(0.06, 0, 0.26, 0) StatusLabel.BackgroundTransparency = 1 StatusLabel.Text = "Status: Idle" StatusLabel.TextColor3 = Color3.fromRGB(170, 170, 180) StatusLabel.Font = Enum.Font.Gotham StatusLabel.TextSize = 11 StatusLabel.TextXAlignment = Enum.TextXAlignment.Left StatusLabel.Parent = MainFrame local ToggleButton = Instance.new("TextButton") ToggleButton.Size = UDim2.new(0.88, 0, 0, 38) ToggleButton.Position = UDim2.new(0.06, 0, 0.45, 0) ToggleButton.BackgroundColor3 = Color3.fromRGB(200, 50, 50) ToggleButton.Text = "OFF (Press Q or Click)" ToggleButton.TextColor3 = Color3.fromRGB(255, 255, 255) ToggleButton.Font = Enum.Font.GothamMedium ToggleButton.TextSize = 13 ToggleButton.Parent = MainFrame local BtnCorner = Instance.new("UICorner") BtnCorner.CornerRadius = UDim.new(0, 6) BtnCorner.Parent = ToggleButton local CreditLabel = Instance.new("TextLabel") CreditLabel.Size = UDim2.new(1, 0, 0, 18) CreditLabel.Position = UDim2.new(0, 0, 1, -20) CreditLabel.BackgroundTransparency = 1 CreditLabel.Text = "Credit: By NP20K12" CreditLabel.TextColor3 = Color3.fromRGB(120, 120, 130) CreditLabel.Font = Enum.Font.Gotham CreditLabel.TextSize = 10 CreditLabel.Parent = MainFrame local OpenBtn = Instance.new("TextButton") OpenBtn.Size = UDim2.new(0, 70, 0, 30) OpenBtn.Position = UDim2.new(0.5, -35, 0.05, 0) OpenBtn.BackgroundColor3 = Color3.fromRGB(30, 30, 35) OpenBtn.Text = "Open" OpenBtn.TextColor3 = Color3.fromRGB(255, 255, 255) OpenBtn.Font = Enum.Font.GothamBold OpenBtn.TextSize = 13 OpenBtn.Visible = false OpenBtn.Active = true OpenBtn.Draggable = true OpenBtn.Parent = ScreenGui local OpenCorner = Instance.new("UICorner") OpenCorner.CornerRadius = UDim.new(0, 6) OpenCorner.Parent = OpenBtn local OpenStroke = Instance.new("UIStroke") OpenStroke.Color = Color3.fromRGB(80, 80, 95) OpenStroke.Thickness = 1.5 OpenStroke.Parent = OpenBtn MinimizeBtn.MouseButton1Click:Connect(function() MainFrame.Visible = false OpenBtn.Visible = true end) OpenBtn.MouseButton1Click:Connect(function() OpenBtn.Visible = false MainFrame.Visible = true end) CloseBtn.MouseButton1Click:Connect(function() ScreenGui:Destroy() end) local function ToggleFarm() local currentFolder = Workspace:FindFirstChild("AutumnApples") if not currentFolder then IsFarming = false AppleNotFoundToken += 1 AppleNotFoundShown = false ToggleButton.Text = "OFF (Press Q or Click)" ToggleButton.BackgroundColor3 = Color3.fromRGB(200, 50, 50) StatusLabel.Text = "Status: Apple not found" return end if currentFolder ~= AppleFolder then BindAppleFolder(currentFolder) end IsFarming = not IsFarming if IsFarming then AppleNotFoundShown = false AppleNotFoundToken += 1 ToggleButton.Text = "ON (Press Q or Click)" ToggleButton.BackgroundColor3 = Color3.fromRGB(50, 180, 80) else AppleNotFoundToken += 1 AppleNotFoundShown = false ToggleButton.Text = "OFF (Press Q or Click)" ToggleButton.BackgroundColor3 = Color3.fromRGB(200, 50, 50) StatusLabel.Text = "Status: Idle" if CurrentTween then CurrentTween:Cancel() CurrentTween = nil end end end ToggleButton.MouseButton1Click:Connect(ToggleFarm) InputConn = UserInputService.InputBegan:Connect(function(input, gameProcessed) if not gameProcessed and input.KeyCode == Enum.KeyCode.Q then ToggleFarm() end end) local function getNearestModel(hrpPosition) if not AppleFolder or not AppleFolder.Parent then return nil, MaxRange end local nearestModel = nil local shortestDist = MaxRange for model, _ in pairs(CachedModels) do if model and model.Parent and model:IsDescendantOf(AppleFolder) then local pos = getModelPosition(model) if pos then local dist = (hrpPosition - pos).Magnitude if dist <= shortestDist then shortestDist = dist nearestModel = model end end else CachedModels[model] = nil end end return nearestModel, shortestDist end local function ShowAppleNotFound() if AppleNotFoundShown then return end AppleNotFoundShown = true AppleNotFoundToken += 1 local currentToken = AppleNotFoundToken StatusLabel.Text = "Status: Apple not found" task.delay(1.5, function() if not ScreenGui or not ScreenGui.Parent then return end if IsFarming and AppleNotFoundShown and AppleNotFoundToken == currentToken and StatusLabel.Text == "Status: Apple not found" then StatusLabel.Text = "Status: Idle" end end) end local function ResetAppleNotFound() AppleNotFoundShown = false AppleNotFoundToken += 1 end task.spawn(function() while ScreenGui and ScreenGui.Parent do task.wait(0.1) if IsFarming then if not AppleFolder or not AppleFolder.Parent then IsFarming = false AppleNotFoundToken += 1 AppleNotFoundShown = false ToggleButton.Text = "OFF (Press Q or Click)" ToggleButton.BackgroundColor3 = Color3.fromRGB(200, 50, 50) StatusLabel.Text = "Status: Apple not found" if CurrentTween then CurrentTween:Cancel() CurrentTween = nil end continue end local char = LocalPlayer.Character local hrp = char and char:FindFirstChild("HumanoidRootPart") local humanoid = char and char:FindFirstChildWhichIsA("Humanoid") if hrp and humanoid and humanoid.Health > 0 then local targetModel, distance = getNearestModel(hrp.Position) if targetModel and IsFarming then ResetAppleNotFound() local targetPos = getModelPosition(targetModel) if targetPos then StatusLabel.Text = "Status: Flying" hrp.Velocity = Vector3.new(0, 0, 0) local duration = distance / FlySpeed local tweenInfo = TweenInfo.new(duration, Enum.EasingStyle.Linear) CurrentTween = TweenService:Create(hrp, tweenInfo, { CFrame = CFrame.new(targetPos + Vector3.new(0, 1.5, 0)) }) CurrentTween:Play() while CurrentTween and CurrentTween.PlaybackState == Enum.PlaybackState.Playing do if not IsFarming or not targetModel or not targetModel.Parent or not ScreenGui or not ScreenGui.Parent then CurrentTween:Cancel() CurrentTween = nil break end hrp.AssemblyLinearVelocity = Vector3.zero task.wait(0.01) end CurrentTween = nil end else ShowAppleNotFound() if CurrentTween then CurrentTween:Cancel() CurrentTween = nil end end end else if AppleFolder and AppleFolder.Parent and StatusLabel.Text ~= "Status: Apple not found" then StatusLabel.Text = "Status: Idle" end end end end)