Im trying to make a idle stance for the player IF their holding a katana weapon

There are two ways I can think of right now to let walk animation play.

  1. Set appropriate animation priority.

When multiple animations play at the same time, the one with higher priority level overwrites the less prior one. We know 4 priority levels (lowest to highest): core, idle, movement and action. Set your animation priority to lower level.

  1. Stopping the animation

You can simply stop animation once player starts moving around. Using Play() and Stop() methods, you can play animation at correct times.

What can be improved in your script?

Firstly, humanoid:LoadAnimation() is deprecated in favour of animator:LoadAnimation(). Animator shares very similar functions, but is encouraged to be used in newer work for the reasons explained in the following article: Deprecating LoadAnimation on Humanoid and AnimationController

Secondly, don’t load animations server-side. Animations loaded from local script do replicate and result in similar outcomes, while not burdening the server with unnecessary processes.

Write the same code for local script.

If you decide to choose the second option, perhaps consider using

humanoid.Running:Connect(function(speed)
    if (speed > 0 and animation.IsPlaying) then
        animation:Stop()
    elseif (speed <= 0 and not animation.IsPlaying) then
        animation:Play()
end)

Each time player starts running stop playing the animation, under the condition that it is still playing, and vice versa.

EDIT I’d personally go for the first option almost without doubt. I also didn’t get the chance to test anything.

EDIT (2) @StarJ3M

The whole animation part belongs in a local script in StarterCharacter scripts. The humanoid.Running event was just an idea, but you’ll have to figure out what suits your script best. I may have done a typo as well, because I’m writing on a phone.

3 Likes