UNIVERSAL   Anti AFK
Key RequiredUniversal

UNIVERSAL Anti AFK

Universal Scriptitz__r4m_itz__r4m_ 601 views 754 executesUpdated Mar 4, 2026
5.0/ 5(1 votes)
10100% Positive
Lua Script•136 lines (3676 chars)
--// Idk if this script is bannable, but be careful.

--// Service
local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")
local UserInputService = game:GetService("UserInputService")
local VirtualUser = game:GetService("VirtualUser")

local player = Players.LocalPlayer

--// Timer
local afkSeconds = 0
local lastInputTime = tick()

--// GUI
local ScreenGui = Instance.new("ScreenGui")
ScreenGui.Parent = game.CoreGui
ScreenGui.ResetOnSpawn = false
ScreenGui.DisplayOrder = 999999

-- Frames
local Main = Instance.new("Frame", ScreenGui)
Main.Size = UDim2.new(0, 420, 0, 200)
Main.Position = UDim2.new(0.35, 0, 0.35, 0)
Main.BackgroundColor3 = Color3.fromRGB(10,10,10)
Main.Active = true
Instance.new("UICorner", Main).CornerRadius = UDim.new(0,14)

local Stroke = Instance.new("UIStroke", Main)
Stroke.Color = Color3.fromRGB(255,140,0)
Stroke.Thickness = 2

-- GUI Anim
Main.Size = UDim2.new(0,0,0,0)
TweenService:Create(Main, TweenInfo.new(0.4, Enum.EasingStyle.Back), {
	Size = UDim2.new(0,420,0,200)
}):Play()

-- Drag
local dragging, dragInput, dragStart, startPos

Main.InputBegan:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		dragging = true
		dragStart = input.Position
		startPos = Main.Position
	end
end)

UserInputService.InputEnded:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		dragging = false
	end
end)

UserInputService.InputChanged:Connect(function(input)
	if dragging and input.UserInputType == Enum.UserInputType.MouseMovement then
		local delta = input.Position - dragStart
		Main.Position = UDim2.new(
			startPos.X.Scale,
			startPos.X.Offset + delta.X,
			startPos.Y.Scale,
			startPos.Y.Offset + delta.Y
		)
	end
end)

-- Title
local Title = Instance.new("TextLabel", Main)
Title.Size = UDim2.new(1, -20, 0, 40)
Title.Position = UDim2.new(0,15,0,5)
Title.BackgroundTransparency = 1
Title.Text = "Anti-AFK by: itz__r4m_"
Title.TextColor3 = Color3.fromRGB(255,140,0)
Title.Font = Enum.Font.GothamBold
Title.TextSize = 18
Title.TextXAlignment = Enum.TextXAlignment.Left

-- Timer
local TimeLabel = Instance.new("TextLabel", Main)
TimeLabel.Size = UDim2.new(1, -40, 0, 50)
TimeLabel.Position = UDim2.new(0,20,0,70)
TimeLabel.BackgroundColor3 = Color3.fromRGB(20,20,20)
TimeLabel.TextColor3 = Color3.fromRGB(255,140,0)
TimeLabel.Font = Enum.Font.GothamBold
TimeLabel.TextSize = 20
TimeLabel.Text = "AFK Time: 00:00:00"
Instance.new("UICorner", TimeLabel).CornerRadius = UDim.new(0,10)
Instance.new("UIStroke", TimeLabel).Color = Color3.fromRGB(255,140,0)

-- Notification
local NotifySound = Instance.new("Sound", Main)
NotifySound.SoundId = "rbxassetid://9118823102" -- You can change the sound btw
NotifySound.Volume = 1

-- Detecter
UserInputService.InputBegan:Connect(function()
	lastInputTime = tick()
	afkSeconds = 0
end)

-- Time reset
local function formatTime(seconds)
	local hrs = math.floor(seconds / 3600)
	local mins = math.floor((seconds % 3600) / 60)
	local secs = seconds % 60
	return string.format("%02d:%02d:%02d", hrs, mins, secs)
end

-- System
task.spawn(function()
	while true do
		task.wait(1)
		
		afkSeconds = math.floor(tick() - lastInputTime)
		TimeLabel.Text = "AFK Time: "..formatTime(afkSeconds)
		
		-- Minutes
		if afkSeconds >= 1140 then
			lastInputTime = tick()
			afkSeconds = 0
			
			-- Activity
			VirtualUser:CaptureController()
			VirtualUser:ClickButton2(Vector2.new())
			
			-- Visual Jump
			local char = player.Character
			if char and char:FindFirstChild("Humanoid") then
				char.Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
			end
			
			NotifySound:Play()
		end
	end
end)

Features & Information

-- Universal Anti-AFK -- The character jumps every 19 minutes. The GUI has a timer. Anti-AFK lol ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ thanks you Chat GPT lulz and you too! ^^
#AFK#Anti AFK#UNIVERSAL

Community Comments (1)

itz__r4m_itz__r4m_Mar 4, 2026(edited)

I think the sound isn't working :steamsad: edit: You can change the sound if you want, it's just decorative btw

More Scripts for Universal Scripts