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

How do you detect if your character has moved?

I'm trying to detect if my character has moved using this script:


local hrp = script.Parent.Parent:FindFirstChild("HumanoidRootPart")

hrp.Changed:Connect(function(p)
	print(p)
    if p == "Position" then
		print("Your position has changed!")
    end
end)

but for some reason it won't work

Edit: Nevermind i just put the script in the wrong place. If i put the script in starter player, then it works!

2 comments

0

Connect to the Changed instance in the HumanoidRootPart. It will fire whenever the player moves.

0

changed doesnt fire on busy events, such as position

1 answer

✓ Accepted answer

You can use a Humanoid.Running Event. There are other events but I forgot. So this is the script

char = script.Parent.Parent
hum = char:WaitForChild("Humanoid")

hum.Running:Connect(function(Speed)
	if Speed > 0 then
		--code
	end
end

click here for more

5 comments

0

oops

0

u could also use the StateChanged event for more precision

0

k

0

the Speed is how fast the player is moving

0

yeah it would be Enum.HumanoidStateType.Running

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