How could I override an animation

So I’m making an RPG game with my friend @Tric_k
and I have a sword animation and a walking animation when I’m walking with the sword out my walking animation doesn’t work why?

here is the sword script

local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local anim = script.Parent:WaitForChild("Equip")
local EquipAnim = char:WaitForChild("Humanoid"):LoadAnimation(anim)
local tool = script.Parent

tool.Equipped:Connect(function()
	EquipAnim:Play()
	print("Anim played")
end)

tool.Unequipped:Connect(function()
	EquipAnim:Stop()
	print("Anim stopped")
end)

Here is my walk script

local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local anim = script.Parent:WaitForChild("Walk")
local anim2stop = game.StarterPack.BeginnerSword:WaitForChild("Equip")
local anim2stopV2 = char:WaitForChild("Humanoid"):LoadAnimation(anim2stop)
local WalkAnim = char:WaitForChild("Humanoid"):LoadAnimation(anim)

UIS.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.W then
		anim2stopV2:Stop()
		WalkAnim:Play()
	end
end)
1 Like

You can get the playing Animation Tracks and stop them? (I’m pretty sure this is deprecated though.)

You can change the animation priority to Action, this is especially for sword animations and tool holding.

image

some animation priority override others, as @aeventy said.

1 Like