MaxproGlitcher

Anti AFK 2

Oct 31st, 2024
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.92 KB | None | 0 0
  1. local userInputService = game:GetService("UserInputService")
  2. local virtualUser = game:GetService("VirtualUser")
  3. local AfkEnabled = false
  4. local timeInAfk = 0
  5.  
  6. local screenGui = Instance.new("ScreenGui")
  7. screenGui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
  8. screenGui.ResetOnSpawn = false
  9.  
  10. local mainFrame = Instance.new("Frame")
  11. mainFrame.Parent = screenGui
  12. mainFrame.Size = UDim2.new(0, 300, 0, 50)
  13. mainFrame.Position = UDim2.new(0.5, -150, 0.1, -60)
  14. mainFrame.BackgroundColor3 = Color3.fromRGB(20, 20, 30)
  15. mainFrame.BorderSizePixel = 0
  16. mainFrame.AnchorPoint = Vector2.new(0.5, 0.5)
  17. mainFrame.Visible = true
  18. mainFrame.Active = true
  19. mainFrame.Draggable = true
  20.  
  21. local mainFrameCorner = Instance.new("UICorner")
  22. mainFrameCorner.CornerRadius = UDim.new(0, 10)
  23. mainFrameCorner.Parent = mainFrame
  24.  
  25. local timeLabel = Instance.new("TextLabel")
  26. timeLabel.Parent = mainFrame
  27. timeLabel.Size = UDim2.new(0.6, 0, 1, 0)
  28. timeLabel.Position = UDim2.new(0.2, 0, 0, 0)
  29. timeLabel.BackgroundTransparency = 1
  30. timeLabel.Text = "0s 0m 0h"
  31. timeLabel.TextColor3 = Color3.fromRGB(200, 200, 255)
  32. timeLabel.TextScaled = true
  33. timeLabel.Font = Enum.Font.FredokaOne
  34. timeLabel.TextStrokeTransparency = 0.8
  35.  
  36. local playIcon = Instance.new("TextButton")
  37. playIcon.Parent = mainFrame
  38. playIcon.Size = UDim2.new(0.2, 0, 1, 0)
  39. playIcon.Position = UDim2.new(0.8, 0, 0, 0)
  40. playIcon.BackgroundColor3 = Color3.fromRGB(100, 100, 255)
  41. playIcon.Text = "▶"
  42. playIcon.TextColor3 = Color3.fromRGB(255, 255, 255)
  43. playIcon.TextScaled = true
  44. playIcon.BorderSizePixel = 0
  45.  
  46. local stopIcon = Instance.new("TextButton")
  47. stopIcon.Parent = mainFrame
  48. stopIcon.Size = UDim2.new(0.2, 0, 1, 0)
  49. stopIcon.Position = UDim2.new(0.8, 0, 0, 0)
  50. stopIcon.BackgroundColor3 = Color3.fromRGB(100, 100, 255)
  51. stopIcon.Text = "■"
  52. stopIcon.TextColor3 = Color3.fromRGB(255, 255, 255)
  53. stopIcon.TextScaled = true
  54. stopIcon.BorderSizePixel = 0
  55. stopIcon.Visible = false
  56.  
  57. local IconBoxCorner = Instance.new("UICorner")
  58. IconBoxCorner.CornerRadius = UDim.new(0, 10)
  59. IconBoxCorner.Parent = playIcon
  60.  
  61. local IconBox2Corner = Instance.new("UICorner")
  62. IconBox2Corner.CornerRadius = UDim.new(0, 10)
  63. IconBox2Corner.Parent = stopIcon
  64.  
  65. local destroyButton = Instance.new("TextButton")
  66. destroyButton.Parent = mainFrame
  67. destroyButton.Size = UDim2.new(0.2, 0, 1, 0)
  68. destroyButton.Position = UDim2.new(0, 0, 0, 0)
  69. destroyButton.BackgroundColor3 = Color3.fromRGB(100, 100, 255)
  70. destroyButton.Text = "X"
  71. destroyButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  72. destroyButton.TextScaled = true
  73. destroyButton.Font = Enum.Font.FredokaOne
  74. destroyButton.BorderSizePixel = 0
  75.  
  76. local destroyButtonCorner = Instance.new("UICorner")
  77. destroyButtonCorner.CornerRadius = UDim.new(0, 10)
  78. destroyButtonCorner.Parent = destroyButton
  79.  
  80. destroyButton.MouseButton1Click:Connect(function()
  81. mainFrame.Visible = false
  82. end)
  83.  
  84. local function formatAfkTime(seconds)
  85. local hours = math.floor(seconds / 3600)
  86. local minutes = math.floor((seconds % 3600) / 60)
  87. local remainingSeconds = seconds % 60
  88. return tostring(remainingSeconds) .. "s " .. tostring(minutes) .. "m " .. tostring(hours) .. "h"
  89. end
  90.  
  91. local function afkTimer()
  92. spawn(function()
  93. while AfkEnabled do
  94. wait(1)
  95. timeInAfk = timeInAfk + 1
  96. timeLabel.Text = formatAfkTime(timeInAfk)
  97. end
  98. end)
  99. end
  100.  
  101. local function startAfk()
  102. spawn(function()
  103. while AfkEnabled do
  104. wait(60)
  105. virtualUser:CaptureController()
  106. virtualUser:ClickButton2(Vector2.new())
  107. end
  108. end)
  109. end
  110.  
  111. playIcon.MouseButton1Click:Connect(function()
  112. AfkEnabled = true
  113. playIcon.Visible = false
  114. stopIcon.Visible = true
  115. startAfk()
  116. afkTimer()
  117. end)
  118.  
  119. stopIcon.MouseButton1Click:Connect(function()
  120. AfkEnabled = false
  121. timeInAfk = 0
  122. timeLabel.Text = "0s 0m 0h"
  123. playIcon.Visible = true
  124. stopIcon.Visible = false
  125. end)
Add Comment
Please, Sign In to add comment