Anti AFK
Key RequiredUniversal

Anti AFK

Universal Scriptogars_mainogars_main 7.1K views 392 executesUpdated Aug 9, 2025
Unrated
00
Lua Script•209 lines (6397 chars)
-- Auto Move with Blue Target Marker and Close Button
-- LocalScript in StarterPlayer > StarterPlayerScripts

local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local Debris = game:GetService("Debris")
local player = Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")

-- CONFIG --
local BASE_INTERVAL = 60         -- seconds between moves
local HASTE_MULTIPLIER = 2       -- hurry speed multiplier
local TARGET_DISTANCE = 10       -- studs in front/behind
-- END CONFIG --

local autoMoveEnabled = false
local hurryEnabled = false
local countdown = BASE_INTERVAL
local character
local nextDirection = -1 -- start moving backward first
local menuClosed = false

-- Handle respawn
local function onCharacterAdded(char)
	character = char
end
player.CharacterAdded:Connect(onCharacterAdded)
if player.Character then
	onCharacterAdded(player.Character)
end

-- Clean old UI
local old = playerGui:FindFirstChild("AutoMoveUI")
if old then old:Destroy() end

-- UI
local screenGui = Instance.new("ScreenGui")
screenGui.Name = "AutoMoveUI"
screenGui.Parent = playerGui
screenGui.ResetOnSpawn = false

local panel = Instance.new("Frame")
panel.Size = UDim2.new(0, 240, 0, 110)
panel.Position = UDim2.new(0, 20, 0, 20)
panel.BackgroundColor3 = Color3.fromRGB(28, 28, 30)
panel.BorderSizePixel = 0
panel.Parent = screenGui
Instance.new("UICorner", panel).CornerRadius = UDim.new(0, 12)

-- Close button (X)
local closeButton = Instance.new("TextButton")
closeButton.Size = UDim2.new(0, 24, 0, 24)
closeButton.Position = UDim2.new(1, -28, 0, 4)
closeButton.BackgroundColor3 = Color3.fromRGB(180, 40, 40)
closeButton.TextColor3 = Color3.fromRGB(255, 255, 255)
closeButton.Font = Enum.Font.GothamBold
closeButton.TextSize = 18
closeButton.Text = "X"
closeButton.Parent = panel
Instance.new("UICorner", closeButton).CornerRadius = UDim.new(0, 12)

closeButton.MouseButton1Click:Connect(function()
	menuClosed = true
	autoMoveEnabled = false
	screenGui:Destroy()
end)

local title = Instance.new("TextLabel")
title.Size = UDim2.new(1, -20, 0, 28)
title.Position = UDim2.new(0, 10, 0, 8)
title.BackgroundTransparency = 1
title.Text = "Auto Move"
title.Font = Enum.Font.GothamBold
title.TextSize = 18
title.TextColor3 = Color3.fromRGB(245, 245, 245)
title.TextXAlignment = Enum.TextXAlignment.Left
title.Parent = panel

local toggleButton = Instance.new("TextButton")
toggleButton.Size = UDim2.new(0.6, -12, 0, 36)
toggleButton.Position = UDim2.new(0, 10, 0, 40)
toggleButton.BackgroundColor3 = Color3.fromRGB(60, 130, 255)
toggleButton.TextColor3 = Color3.fromRGB(255, 255, 255)
toggleButton.Font = Enum.Font.GothamBold
toggleButton.TextSize = 16
toggleButton.Text = "Auto: OFF"
toggleButton.Parent = panel
Instance.new("UICorner", toggleButton).CornerRadius = UDim.new(0, 8)

local hurryButton = Instance.new("TextButton")
hurryButton.Size = UDim2.new(0.35, -12, 0, 36)
hurryButton.Position = UDim2.new(0.62, 10, 0, 40)
hurryButton.BackgroundColor3 = Color3.fromRGB(220, 60, 60)
hurryButton.TextColor3 = Color3.fromRGB(255, 255, 255)
hurryButton.Font = Enum.Font.GothamBold
hurryButton.TextSize = 15
hurryButton.Text = "HURRY UP!"
hurryButton.Parent = panel
Instance.new("UICorner", hurryButton).CornerRadius = UDim.new(0, 8)

local countdownLabel = Instance.new("TextLabel")
countdownLabel.Size = UDim2.new(1, -20, 0, 24)
countdownLabel.Position = UDim2.new(0, 10, 0, 82)
countdownLabel.BackgroundTransparency = 1
countdownLabel.Font = Enum.Font.Gotham
countdownLabel.TextSize = 16
countdownLabel.TextColor3 = Color3.fromRGB(220, 220, 220)
countdownLabel.Text = "Next move in: 00:00"
countdownLabel.TextXAlignment = Enum.TextXAlignment.Left
countdownLabel.Parent = panel

-- UI Helpers
local function formatTime(s)
	s = math.max(0, math.floor(s + 0.5))
	local mins = math.floor(s / 60)
	local secs = s % 60
	return string.format("%02d:%02d", mins, secs)
end

local function updateUI()
	if menuClosed then return end
	if autoMoveEnabled then
		toggleButton.Text = "Auto: ON"
		toggleButton.BackgroundColor3 = Color3.fromRGB(0, 200, 120)
	else
		toggleButton.Text = "Auto: OFF"
		toggleButton.BackgroundColor3 = Color3.fromRGB(60, 130, 255)
	end
	if hurryEnabled then
		hurryButton.BackgroundColor3 = Color3.fromRGB(255, 140, 40)
		hurryButton.Text = "HURRY: ON"
	else
		hurryButton.BackgroundColor3 = Color3.fromRGB(220, 60, 60)
		hurryButton.Text = "HURRY UP!"
	end
	if autoMoveEnabled then
		countdownLabel.Text = "Next move in: " .. formatTime(countdown)
	else
		countdownLabel.Text = "Paused — next in: " .. formatTime(countdown)
	end
end

-- Button events
toggleButton.MouseButton1Click:Connect(function()
	if menuClosed then return end
	autoMoveEnabled = not autoMoveEnabled
	if autoMoveEnabled and countdown <= 0 then
		countdown = BASE_INTERVAL
	end
	updateUI()
end)

hurryButton.MouseButton1Click:Connect(function()
	if menuClosed then return end
	hurryEnabled = not hurryEnabled
	updateUI()
end)

-- Movement function
local function performWalk(directionSign)
	if not character or not character:FindFirstChild("Humanoid") or not character:FindFirstChild("HumanoidRootPart") then return end
	local humanoid = character:FindFirstChild("Humanoid")
	local root = character:FindFirstChild("HumanoidRootPart")

	-- Create the target part
	local targetPart = Instance.new("Part")
	targetPart.Size = Vector3.new(1, 1, 1)
	targetPart.Anchored = true
	targetPart.CanCollide = false
	targetPart.Transparency = 0.5
	targetPart.Color = Color3.fromRGB(0, 100, 255) -- blue
	targetPart.Name = "AutoMoveTarget"
	targetPart.Parent = workspace

	-- Position 10 studs in front/back
	local offset = root.CFrame.LookVector * (TARGET_DISTANCE * directionSign)
	targetPart.CFrame = CFrame.new(root.Position + offset)

	-- Move to the target
	humanoid:MoveTo(targetPart.Position)

	-- Fade out the part over 1 second
	task.spawn(function()
		for i = 0.5, 1, 0.05 do
			targetPart.Transparency = i
			task.wait(0.05)
		end
	end)

	-- Remove after 3 seconds
	Debris:AddItem(targetPart, 3)
end

-- Timer Loop
RunService.Heartbeat:Connect(function(delta)
	if menuClosed then return end
	if autoMoveEnabled then
		local speed = hurryEnabled and HASTE_MULTIPLIER or 1
		countdown -= delta * speed
		if countdown <= 0 then
			performWalk(nextDirection)
			nextDirection = -nextDirection -- flip direction
			countdown = BASE_INTERVAL
		end
	end
	updateUI()
end)

updateUI()

Features & Information

Makes it so you cant get kicked for being afk!
#AntiAfk#Universal

Community Comments (1)

I60uI60uNov 12, 2025

it doesnt work

More Scripts for Universal Scripts