How could I Smoothly Swap Animations without having to Move the Character?

Im trying to create a system that changes your animation from Idle to a Holding a Sword Animation when you pull your sword out of your inventory.

But, the animation does not change until you move around a bit. How would you have the animation change as soon as you take it out of your inventory? Thanks!

So far I have tried changing the animation start time and making a seperate animation that pull the sword out but no luck. I have looked around Dev Forum and any fixes never worked or are not for this specific problem. Can anyone help?

Here is my code: (I’m not sure how to nicely post code without Copy and Paste, Sorry)

Summary

local plr = script.Parent.Parent.Parent

local char = plr.Character

local IdleAnim1 = char.Animate.idle.Animation1.AnimationId

local IdleAnim2 = char.Animate.idle.Animation2.AnimationId

local WalkAnim = char.Animate.walk.WalkAnim.AnimationId

local RunAnim = char.Animate.run.RunAnim.AnimationId

local HoldAnim = char.Humanoid:LoadAnimation(script.HoldAnim)

local IdleAnim = char.Humanoid:LoadAnimation(script.IdleAnim)

script.Parent.Equipped:Connect(function()

print(“Weapon Equipped”)

char.Animate.idle.Animation1.AnimationId = “rbxassetid://8501284966”

char.Animate.idle.Animation2.AnimationId = “rbxassetid://8501284966”


char.Animate.walk.WalkAnim.AnimationId = “rbxassetid://8493411070”

char.Animate.run.RunAnim.AnimationId = “rbxassetid://8493411070”


HoldAnim:Play()

HoldAnim:Stop()

print(“IdlePlayed1”)

end)

script.Parent.Unequipped:Connect(function()

print(“Weapon Unequipped”)


char.Animate.idle.Animation1.AnimationId = IdleAnim1

char.Animate.idle.Animation2.AnimationId = IdleAnim2


char.Animate.walk.WalkAnim.AnimationId = WalkAnim

char.Animate.run.RunAnim.AnimationId = RunAnim


IdleAnim:Play()

IdleAnim:Stop()

print(“IdlePlayed2”)

end)

Try this method

local humanoid = char:FindFirstChild("Humanoid")

local ANIMATION = WHERE_YOUR_ANIMATION_IS

local ANIMATION_2 = humanoid:LoadAnimation(ANIMATION) --Load the animation you wanted

ANIMATION_2.Priority = Enum.AnimationPriority.Action --This will override on every animation, You can also try Core, Movement and Idle as well

Action - The highest can override on every animations
Movement - Only override on Idle and Core
Idle - Override the core animations
Core - The lowest, do not override on any animations

Ok, I’ll see if that works. Thanks!

1 Like

The :LoadAnimation() is giving errors. I think they made it so you have to use the Animator. Idk how it works though.
Screen Shot 2022-01-30 at 9.34.08 AM

What, i use it everyday on players, it working perfectly for me. Did you forgot something important?

Hmmmmm maybe. Ill take a look.

Humanoid:LoadAnimation() Is now deprecated.

You can now instead use Animator:LoadAnimation() (Humanoid.Animator:LoadAnimation() in your case)

Deprecated does not mean it is unusable and it’s just a issue with your code.

Ok, Thanks! Ill try using that instead.

1 Like