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

How would i detect when a Humanoid is Idle, Walking, Jumping etc?

Asked by
NexeusX 137
6 years ago

I am trying to make my own animation script for my custom animated NPCs, but i cannot figure out how to detect when the NPC is performing an action such as standing Idle or Walking, i have tried multiple functions for Humanoid but i cannot figure out what to do?

1 answer

Log in to vote
2
Answered by 6 years ago

You can used the Changed event to detect jumping and walking. I guess you can detect if they are idle if the idle animation is playing, but i dont know how to do that. Lets go to the script. Put the script in StarterGui.

local plr = game.Players.LocalPlayer.Character
local debounce = false
local debounce2 = false
plr.Humanoid.Changed:connect(function(prop) --I just said prop instead of property.
    if prop == 'Jump' and not debounce then
        debounce = not debounce
        print(plr.Name..' has jumped!')
        wait()
        debounce = not debounce
    end
end)

plr.Head.Changed:connect(function(prop)
    if prop == 'Position' and not debounce2 then
        debounce2 = not debounce2
        print(plr.Name..' is walking!')
        wait(1)
        debounce2 = not debounce2
    end
end



Ad

Answer this question