I have a custom animation and wanted to implement it for the player. a Humanoid has its own Event which is Running or StateChanged.
The only way I can manage to do this is by checking the player is running or using the StateChanged event.
Humanoid.Running:Connect(function() -- Insert animation here end) --OR Humanoid.StateChanged:Connect(function(OldState, NewState) -- Insert animation here end)
I tried various options:
I tried to check if the player's velocity is equal to 0 (for some reason the velocity never gets to 0)
I tried to check if the NewState will changed to Nil or None when doing nothing (After Running) Since there is a Enum.HumanoidStateType.None but the "NewState" always prints out as Running or nothing at all when stopped running.
I'm just having trouble finding ways to check if the playing is idle.. Or is there a thing out there that I don't know.. to easily check if the player is idle/not moving.
Thanks!
Humanoid.Running returns Speed
which is Humanoid
's current speed, you can check if it's 0 and if it is then he stopped moving
Humanoid.Running:Connect(function(Speed) if (Speed == 0) then --/Humanoid has stopped moving because if Running fired then --\it means that humanoid has moved, if the speed is 0 and he --\moved then obviously he was running bu stopped end end
Is that what do you mean?
Or you want to check if he IS idle right now? You would use Humanoid.MoveDirection, it's a Vector3
value which represents direction in which Humanoid
is moving right now, if it's 0, 0, 0 then he is idle
if ( Humanoid.MoveDirection == Vector3.new(0) ) then --/This will only pass if statement if MoveDirection is 0: --\this means he is not moving end
You could also just constantly update 2 variables, one of which you update 1 second later then the other, and if they're the same you could run the code.