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

Player Moving Function?

Asked by
dyler3 1510 Moderation Voter
10 years ago

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:

1Player=game.Players.LocalPlayer ---Yes I know this requires a LocalScript---
2Player.Character.Torso.Changed:connect(function(Property)
3    if Property="Position" then
4        print("Yay")
5    end
6end)

Anyways, if anyone could help me out, thanks in advance :P

1 answer

Log in to vote
1
Answered by 10 years ago

You can use the Runningevent inside Player.Character.Humanoid. This is fired when the player begins or ends moving.

Example:

01Player = game.Players.LocalPlayer
02repeat wait() until Player.Character -- This waits for the character to spawn in
03 
04Player.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
11end)
0
Thank you! Got my script to work now :D dyler3 1510 — 10y
Ad

Answer this question