Play animation efficiently

I want to keep checking if a condition is true, If yes. Then play this opening animation ONCE and play loop the holding animation. If it’s false then I want to stop the animation along with holding animation.

2 Likes

What purpose is this used for? There might be a different approach.

1 Like

Well am always checking if the player is holding an item. if yes then ill make a variable true.
If that variable is true then I play the opening animation, wait for the opening animation to be done and play the holding animation

Are you looking for a specific tool?

1 Like

you mean like checking if a item is a specific item? No. Any item

1 Like

You can use childadded on the character do a for i,v and if v:IsA(“Tool”)
Now how to play the animation, i dont remember

1 Like

Got the item checking part done, but I don’t know how to play the animation just once since am always checking the item. If the item is there then it’s true, if it’s true then i play the animation.

It will just keep playing the animation which give a 256 anim track error or something

You can play an animation on a local script, on the humanoid

Are you able to send the error code?

Also i dont understand by once, do you mean equip it, play the animation and never play it again? Or is it debounce?

AnimationTrack limit of 256 tracks for one Animator exceeded, new animations will not be played.

1 Like

If holding item then
play this opening item animation ONCE
wait for this animation to stop then
play the looped holding animation
if not holding item then
stop animation

this is in a renderstepped because i need to keep checking if the variable is true, but if its in a renderstepped it is constantly playing the animation

Renderstepped isnt really good for animations, however, here is what i would do.
Id add a variable called “debounce” and set it to false like

local debounce = false 

Once you found the part, you set it to true and before finding it you type

If debounce == true then
--code here
end

Now i dont know any errors when using it, please tell me if there are

It would had been better if you used childadded cause it runs everytime a child was added
Note that when you equip a tool, it would get parented to the character

Where renderstepped runs every fps

Does childadded run once in a render stepped? I can’t add it anywhere than renderstepped because I have to keep checking a variable then play anim if var is true

Are you in a local scriot by any chance?

Let’s ignore everything about holding an item.

How can I run a specific block of code once in a RenderStepped

It’s a module script but the module is being run in local script inside a renderstep

I have never tested if it works in renderstepped, however
It is an event, anything inside the event will wont work until it gets called