Advertisement
MayWeEnjoy

Basic AntiAfk

May 27th, 2025
18
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. -- Basic Anti-Afk script
  2.  
  3. getgenv().afk6464 = true -- true = ON, false = OFF
  4.  
  5. local player = game.Players.LocalPlayer
  6. local VirtualUser = game:GetService("VirtualUser")
  7. local connection
  8.  
  9. local function enableAntiAFK()
  10. if not connection then
  11. print("anti-afk ON")
  12. connection = player.Idled:Connect(function()
  13. if getgenv().afk6464 then
  14. VirtualUser:CaptureController()
  15. VirtualUser:ClickButton2(Vector2.new())
  16. end
  17. end)
  18. end
  19. end
  20.  
  21. local function disableAntiAFK()
  22. if connection then
  23. connection:Disconnect()
  24. connection = nil
  25. print("Anti-AFK OFF")
  26. end
  27. end
  28.  
  29. local function loop()
  30. while true do
  31. if getgenv().afk6464 then
  32. enableAntiAFK()
  33. else
  34. disableAntiAFK()
  35. end
  36. wait(1)
  37. end
  38. end
  39.  
  40. spawn(loop)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement