How would I make an AFK detection system?

How would I make a system (similar to GRPs) in order to detect when a player goes AFK? I have tried to using player.idle, but that takes far longer then what I am trying to achieve.

GRPs system:

Any help is very much appreciated!

3 Likes

Make a local script and put this in it:

local userinputservice = game:GetService("UserInputService")

userinputservice.WindowFocused:Connect(function()
	print("not afk")
end)

userinputservice.WindowFocusReleased:Connect(function()
	print("afk")
end)
6 Likes

instead of printing it you could maybe fire a remote event that makes it so you can get a afk thing ontop of ur head

1 Like

Many players, including myself have the window focused while being AFK. I think a better solution would be to use UserInputService.InputBegan and UserInputService.WindowFocused together.

3 Likes

Thanks a ton! I’ve somehow never heard of WindowFocused before, which goes shows I don’t read the API documentation clearly enough. Thanks for the help!

1 Like

make sure to check the solution under my post and yeah you also could use input began and check if the user hasnt pressed a button in like idk 60 seconds

That seems like a good idea- however I’m just going for something simple right now. I’ll be sure to try that out in the future!

2 Likes