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

How do you detect if your character has moved?

Asked by 5 years ago
Edited 5 years ago

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!

0
Connect to the Changed instance in the HumanoidRootPart. It will fire whenever the player moves. exxtremestuffs 380 — 5y
0
changed doesnt fire on busy events, such as position Gey4Jesus69 2705 — 5y

1 answer

Log in to vote
2
Answered by 5 years ago
Edited 5 years ago

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

0
oops HappyTimIsHim 652 — 5y
0
u could also use the StateChanged event for more precision Gey4Jesus69 2705 — 5y
0
k HappyTimIsHim 652 — 5y
0
the Speed is how fast the player is moving HappyTimIsHim 652 — 5y
0
yeah it would be Enum.HumanoidStateType.Running DeceptiveCaster 3761 — 5y
Ad

Answer this question