Item Equip Animations

I am trying to make the player equip an item, then keep it in their hand.

I know this has to be achieved using another animation which loops in a static position, but I am having trouble playing this animation right after the first one.

First, I load all animations to the animator, using IDs inside of a module script table:

local equipAnim = Instance.new("Animation") -- adds animation
equipAnim.AnimationId = info.EquipAnim

local animator = player.Character.Humanoid.Animator
local load = animator:LoadAnimation(equipAnim) -- loads it
		
local idleAnim = Instance.new("Animation") -- adds animation
idleAnim.AnimationId = info.IdleAnim
		
local idleLoad = animator:LoadAnimation(idleAnim) -- loads it


Then, I clone the correct item and attach it using a Motor6D, but the problem comes when I try to play the animations:

load:Play(0) -- plays animation
load.Stopped:Wait()
		
idleLoad:Play(0)

Here, I am playing the animation with 0 fadeTime to try and have no delay between animations, but it still plays the idle animation slightly after the main animation has ended. There is also delay in general:

This is all being activated by the server, which could be a cause of delay, but even trying it on client, there is still delay. It might also be complicated to have this on the client, since I would have to use remoteEvents to play two client animations in succession.

1 Like

Make sure you have the correct animation priority, aswell as check if the default tool hold animation is interfering with your other animations.

This is due to the fact that you are using .Stopped:Wait()

I would suggest putting a animation event near the end of the animation, then use AnimationTrack:GetMarkerReachedSignal() to play the idle animation.

Using GetMarkerReachedSignal() seems to work most of the time.

There is still some weird delay though, and on top of that, I can’t stop this idle animation as I have a separate function to unequip items:

1 Like

For the delay, try stopping the equip then play the idle animation in the GetMarkerReachedSignal connection, and make sure the connection is being disconnected after its usage.

As for the unequip, I do have a few suggestions if you would like.

1 Like

Thanks!

This does fix the delay between the equip and idle animation, and I would love to hear suggestions for stopping the load animation.

The unequipping is inside a different, similar function, and I don’t know how to stop an animation that that part of the script doesn’t know about

If you are using tools, you could create a connection using

Tool.Unequipped:Once(function()

and stop the idle animation in there.

This is an inherent issue with the signal itself, since it also takes into account the blending time of the animation’s end. I recommend using GetMarkerReachedSignal, or using task.delay, task.wait while subtracting maybe 0.05 - 0.1 second from the Length of the animation.