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.
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.
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.