Tool animation broken?

local humanoid = game.Players.LocalPlayer.Character.Humanoid
local plr = game.Players.LocalPlayer
local tool = plr.Character:FindFirstChild("Axe")
local swing = tool:WaitForChild("SwingAnimation")

tool.Equipped:Connect(function()
	print(swing.Name,swing.ClassName)
	local mouse = plr:GetMouse()
	mouse.Button1Down:Connect(function()
		local animplay = humanoid:LoadAnimation(swing)
	end)
end)

Screen Shot 2020-10-15 at 19.37.05


19:34:42.242 - Stack Begin

[19:34:42.243 - Script 'Players.vf9r.Backpack.Axe.Swing', Line 4](rbxopenscript://www.dummy.com/dummy?scriptGuid=%7B908065f4-9765-429b-9ac8-81aede0cb6ef%7D&gst=2#4)

19:34:42.243 - Stack End

I am trying to make it so when I click with the axe equipped it plays an animation, ut it doesn’t play the animation, and says “WaitForChild” isn’t a thing when referenced with animation. If I don’t use WaitForChild or FindFirstChild when getting an instance, it says that it doesn’t exist.

I think what’s likely happening is that when your character first spawns, your tool is parented to LocalPlayer.Backpack, not Character. You should instead do tool = script.Parent.

As @AstroCode Said , it always precise to use script.Parent , since its getting the tool no matter where it is located.

Now it says " 17:09:27.082 - SwingAnimation is not a valid member of Tool “Players.vf9r.Backpack.Axe”"

Can you show me your Current Script ? I believe that you are missing Something somewhere and also be aware of your Capitalization.

is the animation set as a action?