Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local userInputService = game:GetService("UserInputService")
- local virtualUser = game:GetService("VirtualUser")
- local antiAfkEnabled = false
- local timeInAfk = 0
- local screenGui = Instance.new("ScreenGui")
- screenGui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
- screenGui.ResetOnSpawn = false
- local menuFrame = Instance.new("Frame")
- menuFrame.Parent = screenGui
- menuFrame.Size = UDim2.new(0, 300, 0, 200)
- menuFrame.Position = UDim2.new(0.5, -150, 0.5, -100)
- menuFrame.BackgroundColor3 = Color3.fromRGB(20, 20, 30)
- menuFrame.BorderSizePixel = 0
- menuFrame.AnchorPoint = Vector2.new(0.5, 0.5)
- menuFrame.Visible = true
- menuFrame.Active = true
- menuFrame.Draggable = true
- local corner = Instance.new("UICorner")
- corner.CornerRadius = UDim.new(0, 6)
- corner.Parent = menuFrame
- local titleLabel = Instance.new("TextLabel")
- titleLabel.Parent = menuFrame
- titleLabel.Size = UDim2.new(1, 0, 0, 40)
- titleLabel.Position = UDim2.new(0, 0, 0, 0)
- titleLabel.BackgroundTransparency = 1
- titleLabel.Text = "Anti AFK"
- titleLabel.TextColor3 = Color3.fromRGB(200, 200, 255)
- titleLabel.TextScaled = true
- titleLabel.Font = Enum.Font.FredokaOne
- titleLabel.TextStrokeTransparency = 0.8
- titleLabel.ZIndex = 2
- local sLine = Instance.new("Frame")
- sLine.Parent = menuFrame
- sLine.Size = UDim2.new(1, 0, 0, 2)
- sLine.Position = UDim2.new(0, 0, 0, 40)
- sLine.BackgroundColor3 = Color3.fromRGB(100, 100, 255)
- sLine.ZIndex = 2
- local antiAfkButton = Instance.new("TextButton")
- antiAfkButton.Parent = menuFrame
- antiAfkButton.Size = UDim2.new(0, 180, 0, 40)
- antiAfkButton.Position = UDim2.new(0.5, -90, 0.4, -20)
- antiAfkButton.BackgroundColor3 = Color3.fromRGB(100, 100, 255)
- antiAfkButton.Text = "Anti AFK: OFF"
- antiAfkButton.TextColor3 = Color3.fromRGB(255, 255, 255)
- antiAfkButton.TextScaled = true
- antiAfkButton.Font = Enum.Font.FredokaOne
- antiAfkButton.BorderSizePixel = 0
- antiAfkButton.ZIndex = 2
- local antiAfkCorner = Instance.new("UICorner")
- antiAfkCorner.CornerRadius = UDim.new(0, 6)
- antiAfkCorner.Parent = antiAfkButton
- local afkTimerLabel = Instance.new("TextLabel")
- afkTimerLabel.Parent = menuFrame
- afkTimerLabel.Size = UDim2.new(1, 0, 0, 30)
- afkTimerLabel.Position = UDim2.new(0, 0, 0.7, -30)
- afkTimerLabel.BackgroundTransparency = 1
- afkTimerLabel.Text = "AFK Time"
- afkTimerLabel.TextColor3 = Color3.fromRGB(200, 200, 255)
- afkTimerLabel.TextScaled = true
- afkTimerLabel.Font = Enum.Font.FredokaOne
- afkTimerLabel.TextStrokeTransparency = 0.8
- afkTimerLabel.ZIndex = 2
- local timeDisplayLabel = Instance.new("TextLabel")
- timeDisplayLabel.Parent = menuFrame
- timeDisplayLabel.Size = UDim2.new(1, 0, 0, 30)
- timeDisplayLabel.Position = UDim2.new(0, 0, 0.8, -10)
- timeDisplayLabel.BackgroundTransparency = 1
- timeDisplayLabel.Text = "0s 0m 0h"
- timeDisplayLabel.TextColor3 = Color3.fromRGB(200, 200, 255)
- timeDisplayLabel.TextScaled = true
- timeDisplayLabel.Font = Enum.Font.FredokaOne
- timeDisplayLabel.TextStrokeTransparency = 0.8
- timeDisplayLabel.ZIndex = 2
- local function formatAfkTime(seconds)
- local hours = math.floor(seconds / 3600)
- local minutes = math.floor((seconds % 3600) / 60)
- local remainingSeconds = seconds % 60
- return tostring(remainingSeconds) .. "s " .. tostring(minutes) .. "m " .. tostring(hours) .. "h"
- end
- local function startAfkTimer()
- spawn(function()
- while antiAfkEnabled do
- wait(1)
- timeInAfk = timeInAfk + 1
- timeDisplayLabel.Text = formatAfkTime(timeInAfk)
- end
- end)
- end
- local function startAntiAfk()
- spawn(function()
- while antiAfkEnabled do
- wait(60)
- virtualUser:CaptureController()
- virtualUser:ClickButton2(Vector2.new())
- end
- end)
- end
- antiAfkButton.MouseButton1Click:Connect(function()
- antiAfkEnabled = not antiAfkEnabled
- if antiAfkEnabled then
- antiAfkButton.Text = "Anti AFK: ON"
- startAntiAfk()
- startAfkTimer()
- else
- antiAfkButton.Text = "Anti AFK: OFF"
- timeInAfk = 0
- timeDisplayLabel.Text = "0s 0m 0h"
- end
- end)
- local Cbutton = Instance.new("TextButton")
- Cbutton.Parent = menuFrame
- Cbutton.Size = UDim2.new(0, 30, 0, 30)
- Cbutton.Position = UDim2.new(1, -35, 0, 5)
- Cbutton.BackgroundTransparency = 1
- Cbutton.Text = "X"
- Cbutton.TextColor3 = Color3.fromRGB(100, 100, 255)
- Cbutton.TextScaled = true
- Cbutton.Font = Enum.Font.FredokaOne
- Cbutton.BorderSizePixel = 0
- Cbutton.ZIndex = 3
- Cbutton.MouseButton1Click:Connect(function()
- menuFrame.Visible = false
- end)
Add Comment
Please, Sign In to add comment