Animation won't play

Hello, I am working on a player vs AI game, and I was trying to make a click for an attack animation, and it doesn’t give me any errors, but the animation won’t play, and I’ve put print statements they run perfectly but the animation won’t play Script:

local debounce = false
local plr = nil


script.Parent.Activated:Connect(function()
	if debounce == false then
		debounce = true
			if plr == nil then
			plr = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
	end
	print("activated")
	local anim = script.Parent.Handle.Slash
		local slashanim = script.Parent.Parent:FindFirstChildOfClass("Humanoid").Animator:LoadAnimation(script.Parent.Handle.Slash)
		script.Parent.Handle.Sound:Play()
		slashanim:Play()
		script.Parent.Trail.Enabled = true
		wait(slashanim.Length)
		script.Parent.Trail.Enabled = false
		wait(0.5)
		debounce = false
	end
	print("done")

end)

It also has an idle animation script which works fine.
Edit: Forgot to mention I added a print statement to print the parent of Slashanim and it says “nil”

Edit 2: R15 doesn’t work here’s a little for info

2 Likes

What is the parent of Slashanim. You might be setting it to nil.

I’m trying to set it to the animator inside the humanoid

Try to replace

local slashanim = script.Parent.Parent:FindFirstChildOfClass("Humanoid").Animator:LoadAnimation(script.Parent.Handle.Slash)

With

local Humanoid = script.Parent.Parent:WaitForChild('Humanoid')
local Animator = Humanoid:WaitForChild('Animator')
local slashanim = Animator:LoadAnimation(script.Parent.Handle.Slash)

Don’t think this is the best solution but it could work.

1 Like

Actually, the script works for me. Make sure that the script is in localscript the animation type matches with the player’s RigType.
Like if the player is in R6, make sure that the slash animation is in R6.

That’s why I didn’t change anything with the script because I don’t see any problems with it!

I haven’t thought about that yet…