I've been experimenting lately, and I can't figure out a function(s) that fires when player moves. I've tried using the Changed, and ChangedState functions, neither of which have worked for me. If there is a way to use these, or if there's another way then please help me out.
This is an example of something I've tried:
1 | Player = game.Players.LocalPlayer ---Yes I know this requires a LocalScript--- |
2 | Player.Character.Torso.Changed:connect( function (Property) |
3 | if Property = "Position" then |
4 | print ( "Yay" ) |
5 | end |
6 | end ) |
Anyways, if anyone could help me out, thanks in advance :P
You can use the Running
event inside Player.Character.Humanoid
. This is fired when the player begins or ends moving.
Example:
01 | Player = game.Players.LocalPlayer |
02 | repeat wait() until Player.Character -- This waits for the character to spawn in |
03 |
04 | Player.Character:WaitForChild( "Humanoid" ).Running:connect(speed) |
05 | --You have to include the 'speed' parameter to check if they are starting to run rather than stopping |
06 | if speed > 0 then |
07 | print ( "Player has begun to run!" ) |
08 | else |
09 | print ( "Player has stopped running!" ) |
10 | end |
11 | end ) |