ShoccessX

anti afk rh2

Sep 15th, 2024
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. -- Services
  2. local VirtualUser = game:GetService('VirtualUser')
  3. local StarterGui = game:GetService('StarterGui')
  4. local Players = game:GetService('Players')
  5.  
  6. -- Get the local player
  7. local player = Players.LocalPlayer
  8.  
  9. -- Function to handle idle detection
  10. local function setupAntiAFK()
  11. player.Idled:Connect(function()
  12. VirtualUser:CaptureController()
  13. VirtualUser:ClickButton2(Vector2.new())
  14. end)
  15. end
  16.  
  17. -- Function to disable AFK check scripts
  18. local function disableAFKCheck()
  19. local function disableScriptInGui(gui)
  20. local afkCheckScript = gui:FindFirstChild("AFK.Check")
  21. if afkCheckScript and afkCheckScript:IsA("LocalScript") then
  22. afkCheckScript.Disabled = true
  23. print("AFK.Check script in", gui.Name, "is disabled.")
  24. else
  25. print("AFK.Check script not found or not a LocalScript in", gui.Name, ".")
  26. end
  27. end
  28.  
  29. -- Check in StarterGui
  30. local starterGuiAFKUi = StarterGui:FindFirstChild("AFK.Ui")
  31. if starterGuiAFKUi then
  32. disableScriptInGui(starterGuiAFKUi)
  33. else
  34. print("AFK.Ui not found in StarterGui.")
  35. end
  36.  
  37. -- Check in PlayerGui
  38. local playerGuiAFKUi = player.PlayerGui:FindFirstChild("AFK.Ui")
  39. if playerGuiAFKUi then
  40. disableScriptInGui(playerGuiAFKUi)
  41. else
  42. print("AFK.Ui not found in PlayerGui.")
  43. end
  44. end
  45.  
  46. -- Execute the functions
  47. setupAntiAFK()
  48. disableAFKCheck()
Advertisement
Add Comment
Please, Sign In to add comment