How would I play an animation (walking, jumping, etc) conditionally?

Hey everyone!

I want to get a walking animation to play when I’m holding my sword tool,
but I’m not sure how to implement it. How would I do this?

1 Like

Hi Mate what do you have so far? do you have the sword script etc…

Make a walking animation and set it to Idle. If this doesn’t work then idk. Also is it r6 or r15?

1 Like

You would do something such as this:

local player = game:GetService("Players").LocalPlayer
local tool = script.Parent

local animation = script.swordanimation

local function onEquip()
	local char = player.Character
	local animator = char.Humanoid:FindFirstChildOfClass("Animator")
	local animationTrack = animator:LoadAnimation(animation)
	animationTrack:Play()
end

tool.Equipped:Connect(onEquip)

Make sure to mark as solution if this helped!

1 Like

I’ve made the attack script, but nothing else.