I’ve tried using the Idled event, but it doesn’t ever fire. Maybe I’m doing something wrong. Here is the script:
game:GetService("Players").PlayerAdded:Connect(function(player)
player.Idled:Connect(function()
print("Player is AFK!")
end)
end)
I couldn’t find other solutions here other than the Idled event. I tried using UserInputService, but I’m afraid it would eat up too many resources. The final script that includes AFK detection is for a nametag above the player that says, “AFK!”. Thank you!
First, the Idled event does not fire. As far as I know, this has been the case for the past few years and hasn’t been fixed. If you really want to know if a player is idle, just use UserInputService. It won’t take a lot of resources. Example:
local function inputChanged(input)
idle = tick()
local now = idle
wait(120) --2 minutes
if idle == now then --Check if idle is still equal to now. If so, the player is AFK.
--The player is AFK
end
end
local idle = false
local timer = 0
UIS.InputEnded:Connect(function()
idle = true
while wait(1) do
timer += 1
if not idle then
break
end
if timer >= 180 then
localPlayer:Kick("Been afk for 3 minutes")
break
end
end
end)
UIS.InputBegan:Connect(function()
idle = false
end)
supposing this is old news, but the idled event works in the client, at least for now. it seems to first trigger between 2 and 3 minutes, then every 30 secs afterwards. the callback argument has the total idle time (secs).