-- Services local Players = game:GetService("Players") local UserInputService = game:GetService("UserInputService") local RunService = game:GetService("RunService") -- Player Setup local LocalPlayer = Players.LocalPlayer local PlayerGui = LocalPlayer:WaitForChild("PlayerGui") local AFKActive = false local lastInputTime = tick() local guiName = "AFKBotGui" local InCombat = false local Theme = "Dark" -- Options: "Dark", "Light" -- Settings local MIN_WAIT = 2 local MAX_WAIT = 8 local WALK_RADIUS = 100 local ACTION_NEAR_PLAYERS = true local COMBAT_COOLDOWN = 10 local lastCombatTime = 0 -- Utilities local function Humanoid() return LocalPlayer.Character and LocalPlayer.Character:FindFirstChildOfClass("Humanoid") end local function getRandomPlayerPosition() local otherPlayers = {} for _, p in pairs(Players:GetPlayers()) do if p ~= LocalPlayer and p.Character and p.Character:FindFirstChild("HumanoidRootPart") then table.insert(otherPlayers, p) end end if #otherPlayers > 0 then local target = otherPlayers[math.random(1, #otherPlayers)] return target.Character.HumanoidRootPart.Position end return nil end -- Theme Colors local Themes = { Dark = { Background = Color3.fromRGB(40, 40, 40), Text = Color3.new(1, 1, 1), }, Light = { Background = Color3.fromRGB(220, 220, 220), Text = Color3.new(0, 0, 0), } } -- GUI Setup local function saveGuiPosition(pos) LocalPlayer:SetAttribute("AFKGuiPosX", pos.X.Scale) LocalPlayer:SetAttribute("AFKGuiPosY", pos.Y.Scale) end local function loadGuiPosition() local x = LocalPlayer:GetAttribute("AFKGuiPosX") or 0.015 local y = LocalPlayer:GetAttribute("AFKGuiPosY") or 0.85 return UDim2.new(x, 0, y, 0) end local function createGUI() if PlayerGui:FindFirstChild(guiName) then PlayerGui[guiName]:Destroy() end local themeColors = Themes[Theme] local screenGui = Instance.new("ScreenGui") screenGui.Name = guiName screenGui.ResetOnSpawn = false screenGui.Parent = PlayerGui local toggle = Instance.new("TextButton") toggle.Name = "ToggleButton" toggle.Size = UDim2.new(0, 160, 0, 40) toggle.Position = loadGuiPosition() toggle.BackgroundColor3 = themeColors.Background toggle.TextColor3 = themeColors.Text toggle.Font = Enum.Font.GothamBold toggle.TextSize = 18 toggle.Text = "AFK Bot: OFF" toggle.BorderSizePixel = 0 toggle.Parent = screenGui toggle.Draggable = true toggle.Active = true toggle.MouseButton1Click:Connect(function() if LocalPlayer.Character and Humanoid() then AFKActive = not AFKActive toggle.Text = "AFK Bot: " .. (AFKActive and "ON" or "OFF") end end) toggle.MouseLeave:Connect(function() saveGuiPosition(toggle.Position) end) -- Theme Switcher Button local themeBtn = Instance.new("TextButton") themeBtn.Size = UDim2.new(0, 160, 0, 30) themeBtn.Position = UDim2.new(0, 0, 0, 45) themeBtn.BackgroundColor3 = themeColors.Background themeBtn.TextColor3 = themeColors.Text themeBtn.Font = Enum.Font.Gotham themeBtn.TextSize = 14 themeBtn.Text = "Theme: " .. Theme themeBtn.Parent = screenGui themeBtn.MouseButton1Click:Connect(function() Theme = (Theme == "Dark" and "Light" or "Dark") createGUI() end) end -- Emote/Idle Animation local function playEmote() local h = Humanoid() if not h then return end local animator = h:FindFirstChildWhichIsA("Animator") if animator then local idleAnims = { 507766666, -- Sit 507770239, -- Cheer 507768375, -- Wave } local id = "rbxassetid://" .. tostring(idleAnims[math.random(1, #idleAnims)]) local anim = Instance.new("Animation") anim.AnimationId = id local track = animator:LoadAnimation(anim) track:Play() game.Debris:AddItem(anim, 5) end end -- Behavior Functions local function walk() if InCombat then return end local h = Humanoid() if h then local destination = Vector3.new( math.random(-WALK_RADIUS, WALK_RADIUS), 0, math.random(-WALK_RADIUS, WALK_RADIUS) ) if ACTION_NEAR_PLAYERS then local targetPos = getRandomPlayerPosition() if targetPos then destination = targetPos + Vector3.new(math.random(-5, 5), 0, math.random(-5, 5)) end end h:MoveTo(destination) print("Walking to:", destination) end end local function jump() if InCombat then return end local h = Humanoid() if h then h.Jump = true print("Jumping") end end local function walkAndJump() walk() wait(0.5) jump() end local function idle() playEmote() print("Idling...") end local function chooseAction() local action = math.random(1, 4) if action == 1 then walkAndJump() elseif action == 2 then walk() elseif action == 3 then jump() else idle() end end -- Auto Combat Detection local lastHealth = 100 RunService.Heartbeat:Connect(function() local h = Humanoid() if h then local currentHealth = h.Health if currentHealth < lastHealth then lastCombatTime = tick() InCombat = true end lastHealth = currentHealth -- Exit combat if time passed if tick() - lastCombatTime > COMBAT_COOLDOWN then InCombat = false end end end) -- Input Tracking UserInputService.InputBegan:Connect(function() lastInputTime = tick() end) -- Respawn GUI Restore LocalPlayer.CharacterAdded:Connect(function() wait(1) createGUI() end) -- Main Bot Loop coroutine.wrap(function() createGUI() while true do if AFKActive or (tick() - lastInputTime > 60) then if not InCombat then chooseAction() end end wait(math.random(MIN_WAIT, MAX_WAIT)) end end)()