Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

How To Best Detect Movement?

Asked by
Vezious 310 Moderation Voter
8 years ago

So I need to know which way is the best to detect Players Movement. Because I need one that activates by at the beginning of the round, checking if they're moving or not, and then one that activates if they ever stop moving. A way that Supports all devices.

1 answer

Log in to vote
1
Answered by
4Bros 550 Moderation Voter
8 years ago

You should use the Running event located in the humanoid. This event fires whenever the humanoid begins walking and stops walking, and also passes a parameter of the humanoid's speed.

local workspace = game:GetService'Workspace'


workspace.Player.Humanoid.Running:connect(function(speed) -- Speed is the humanoid's WalkSpeed
    if speed > 0 then
        print("Player is walking")
    else
        print("Player has stopped")
    end
end)




Ad

Answer this question