I want to check how long someone is idle for but the event never fires, I even tried the script that was used as an example on the documentation
This event fires once after about 2 minutes has passed of absolutely no input, and periodically after that.
Are you sure that you are referencing the correct player object? Are you getting any errors in the output?
No errors and im aware of the time elapsed thing.
Im 99.9% sure I did it properly
Can we see your code to double check that it is proper? Where is the script located? Is it a Server or Local Script?
server in backpack
script.Parent.Parent.Idled:Connect(function(time)
print("Player has been idle for " .. time .. " seconds")
end)
And you sure you are pressing no keyboard keys, and making no mouse presses or movements?
ya. I even got disconected by roblox for being idle for 20 mins, but it was when I was using a different script (Pretty similar). but I did test the example and it didnt work.
It might be that the script isn’t running in the backpack. If you put a print at the start of the scripts, does it appear in the output when the game is played?
yea the script works but the idle doesnt
Have you tested the event yourself to see if it works for you
I just gave it a test, and it does seem that Scripts can’t run in the backpack. Try moving the Script to work inside of the Character / StarterCharacterScripts, and see if that works.
ServerScripts do not run in the backpack if i remember correctly.
Make a script in serverscriptservice that has this code:
game.Players.PlayerAdded:Connect(function(Player)
Player.Idled:Connect(function(Time)
print("Player was idle for", Time, "seconds")
end)
end)
Another plus of this is having connections instead of scripts that get cloned for each player reduces the instance count, and thus the memory usage.
Scripts do run in backpack…
Yea thats how I plan on doing it and had it originally but it wasnt firing so I put it down to the simplest thing possible and it still didnt work
This is very strange. Whenever I try to run it Script inside the Backpack it doesn’t run.
Apparently Scripts do run in the Backpack, and something is wrong with my client.
Scripts do run its just the event thats the problem, try printing something
No luck still with this working
ok I think I found out that it only work local
It would make sense to be local, since game function can be handled entirely on client and the server never knowing if the person is actively playing. (If no player char is being replicated)