Basically, my scenario is: Right when players spawn they get an instant forcefield and it should always be there as long as the player doesn't move. I want to check if the player is not idle anymore to remove the forcefield.
delay(0, function() for _, Player in next, Players:GetPlayers() do local Character = Player.Character or Player.CharacterAdded:wait() Player.Idled:wait() if Character:FindFirstChild('ForceField') then Character.Forcefield:Remove() end end end)
My attempt doesn't work
You could try to use MoveDirection, which tells us what direction the humanoid is moving in. https://developer.roblox.com/en-us/api-reference/property/Humanoid/MoveDirection
if humanoid.MoveDirection.Magnitude > 0 then --we are walking if Character:FindFirstChild('ForceField') then Character.Forcefield:Remove() end end
I think you mean something like this:
game.Players.LocalPlayer.Idled:Connect(function() print("you idled.") end)