Player.Idled Help

In the article Player | Roblox Creator Documentation I tried using it on a serverscript in serverscriptservice but it doesn’t work. Here is my script. :arrow_down:

local plr = game.Players.LocalPlayer

plr.Idled:Connect(function()
	plr.Character.Head.NameTag.AFK.Visible = true
end)

Edit: Error: ServerScriptService.AFKScript:3: attempt to index nil with ‘Idled’

EDITED (2021-04-08)

I edited this post just in case anyone read this. Apparently, player.Idled event currently doesn’t happen server-side. That is rather unexpected at the first glance.

Furthermore, Player.Idled documentation doesn’t mention this anywhere explicitely. However the facts make sense at the same time, because Player.Idled fires after a time period - 2 minutes to be exact - of no user input. Client input is not “server concern”, thus this connection only working client-side in fact makes sense.


local player = game:GetService("Players").LocalPlayer
player.Idled:Connect(function()
	player.Character.Head.NameTag.AFK.Visible = true
end)

As opposed to .Idled event, Humanoid.Running event is still triggered and detected by the server (although it’s not advised to stick to that practice, because such type of connections burder the server).

You cannot define “LocalPlayer” on the server you can only do it on the client
Try putting this in a .PlayerAdded event

Edit: apparently player.Idled doesn’t work on the server? Oh well disregard this

This is undocumented, but it only works on the client. It might work sometimes, but the client can fire it accurately.

So it’s best you have the client tell the server that it has been idle.

1 Like

I put this into my server script but it’s still not working.

game:GetService("Players").PlayerAdded:Connect(function(player)
	player.Idled:Connect(function()
		player.Character.Head.NameTag.AFK.Visible = true
	end)
end)

Where should I put the local script? In StarterPlayerScripts?

Anywhere that fits you, but StarterPlayerScripts is a good spot.

This still isn’t working, I want the AFK to happen immediately when they still have Roblox open but they switch to another window e.g. a search engine or something. My script right now is :arrow_down:

local player = game:GetService("Players").LocalPlayer

player.Idled:Connect(function()
	player.Character.Head.NameTag.AFK.Visible = true
end)

Okay, well for that you have to use two completely different events.

3 Likes