Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Player Moving Function?

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:

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

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

1 answer

✓ Accepted answer

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

Example:

Player = game.Players.LocalPlayer
repeat wait() until Player.Character -- This waits for the character to spawn in

Player.Character:WaitForChild("Humanoid").Running:connect(speed)
	--You have to include the 'speed' parameter to check if they are starting to run rather than stopping
	if speed > 0 then
		print("Player has begun to run!")
	else
		print("Player has stopped running!")
	end
end)

1 comment

0

Thank you! Got my script to work now :D

This discussion is preserved as it was. New answers, comments, and votes are closed.