Animation doesn't play

I am trying to make a animation for a dagger tool. The animation stops the player from moving or jumping, and at the end kills the player.

There are no errors within the Output but the animations don’t play and after a few seconds the tool disappears from my inventory.

local AnimationsFolder = script.Parent.Animations

local Activate = AnimationsFolder.DaggerActivation
local Idle = AnimationsFolder.DaggerIdle

local ActivateAnimation = Activate
local IdleAnimation = Idle

local db = false

-- Main Script --

script.Parent.Equipped:Connect(function()
	local function ChangeSpeed(x,z) -- Makes the players speed 0
		script.Parent.Parent.Humanoid.WalkSpeed = x
		script.Parent.Parent.Humanoid.JumpPower = z
	end
	
	ActivateAnimation = script.Parent.Parent.Humanoid:WaitForChild("Animator"):LoadAnimation(Activate)
	IdleAnimation = script.Parent.Parent.Humanoid:WaitForChild("Animator"):LoadAnimation(Idle) --None

	IdleAnimation:Play()
end)

-- Animation that will play when you Click with the Tool Equipped --
script.Parent.Activated:Connect(function()
	if not db then
		db = true

		ActivateAnimation:Play()

		task.wait(1)
		
		script.Parent.Parent.Humanoid.Health = 0
	end
end)

-- Animation that will be stopped upon unequipping your tool. --
script.Parent.Unequipped:Connect(function()

	ActivateAnimation:Stop()
	IdleAnimation:Stop()

end)

image_2021-10-16_165215

I assume this is the reason why the player still can move or jump when they equip the tool because you never called this function in the scope.

I suspect the animations doesn’t play because you got the wrong class name for the Animation instances, it seems like you got a KeyframeSequence to store the Animations which could be the issue. Try saving it to roblox, copy the asset ID, replace the animation instance with an actual Animation instance and paste in the asset ID inside the properties, then use it to load animation.

I tried it but the same issue still happens.

It’s because the animationTrack has the priority as idle.

IdleAnimation = script.Parent.Parent.Humanoid:WaitForChild("Animator"):LoadAnimation(Idle)

IdleAnimation.Priority = Enum.AnimationPriority.Action

idleAnimation:Play()

So far I have to to where the animation plays and I cant move nor jump which is good.
But the Idle animation loops and I only want it to play once and stay on the last frame is that possible. And the tool still disappears from my inventory.

local AnimationsFolder = script.Parent.Animations

local Activate = AnimationsFolder.Activate
local Idle = AnimationsFolder.Idle

local ActivateAnimation = Activate
local IdleAnimation = Idle

local db = false

-- Main Script --

script.Parent.Equipped:Connect(function()
	
	ActivateAnimation = script.Parent.Parent.Humanoid:WaitForChild("Animator"):LoadAnimation(Activate)
	IdleAnimation = script.Parent.Parent.Humanoid:WaitForChild("Animator"):LoadAnimation(Idle) --None

	IdleAnimation:Play()
	
	local function ChangeSpeed(x,z) -- Makes the players speed 0
		script.Parent.Parent.Humanoid.WalkSpeed = x
		script.Parent.Parent.Humanoid.JumpPower = z
	end

	ChangeSpeed()
end)

-- Animation that will play when you Click with the Tool Equipped --
script.Parent.Activated:Connect(function()
	if not db then
		db = true

		ActivateAnimation:Play()

		task.wait(1)
		
	end
end)

-- Animation that will be stopped upon unequipping your tool. --
script.Parent.Unequipped:Connect(function()

	ActivateAnimation:Stop()
	IdleAnimation:Stop()
	
	local function ChangeSpeed()
		script.Parent.Parent.Humanoid.WalkSpeed = 15
		script.Parent.Parent.Humanoid.JumpPower = 50
		
		ChangeSpeed()
	end
end)

image_2021-10-16_182717