How would I detect if the player is doing an animation?

I want to know how to make a script that can detect if the player is doing an animation.

And if they are it prints something such as “is animating” or something.

if NameOfYourAnimation.Playing == true then

Code goes under that if statement

1 Like

It’s that simple? man I’m an idiot, but it would be

if
nameofanimation.Playing == true then ??

Yes but replace nameofanimation to the actual or variable name of your animation

I think you’re referring to

If ANIMHERE.IsPlaying then
-- do stuff
end

Would I put this in a LocalScript or a ServerScript?

Works regardless of script. It’s universal.

I used this code:

local animname = game.Workspace.Animation

if animname.IsPlaying == false then

print(“IsPlaying”)

end

ignore the false part, but its not working. It says “IsPlaying is not a valid member of Animation”

You have to load it from a humanoid and THEN check if it works!

It should be an animation track.

1 Like

https://developer.roblox.com/en-us/api-reference/function/Humanoid/GetPlayingAnimationTracks

As @vyexon said, it has to be an AnimationTrack.

AnimationTracks have an IsPlaying value, not Animations, which are the containers for AnimationTracks to be loaded onto.

You can read more on the AnimationTrack here.

Animation has to be loaded in a humanoid class first to be checked.

So what would the code have to look like

You’re gonna have to use load the humanoid animation first using this Animator:LoadAnimation then afterwards you can just detect if it’s playing or not using IsPlaying