I was wondering if anyone can tell me if there is something like .Moved
for a Player
's Humanoid
to detect when a Player
moves, ignoring the Idle Animation
. Only thing I have been able to think of is using a while wait() do
loop.
Script I tried:
local Player = game.Players.LocalPlayer local Pos = Player.Character.Torso.Position while wait() do if Pos ~= Player.Character.Torso.Position then Pos = Player.Character.Torso.Position -- print(Pos) end end
Any help appreciated.
To expand on DevSean's wiki link, there are multiple events for the Humanoid class that will be fired depending on the Humanoid's state. Running is one such event. There are also events for Climbing, Swimming, etc, but without context it's easy to assume that Running is the event you want. Thus, you want something like this:
local Player = game.Players.LocalPlayer Player.Character.Humanoid.Running:connect(function() --your code end)
There's also a speed argument for the Running event. You're better off using something closer to the example in the Wiki, which makes use of the speed argument; my code will fire again when you stop walking.