"LoadAnimation requires an Animation object"

Hello!
I’ve been making a script that when you die, a death animation plays.

My script works… besides one part.

It gives me the error “LoadAnimation requires an Animation object…”

Heres a local script in StarterCharacterScripts:

local Player = game.Players.LocalPlayer

local Humanoid = Player.Character.Humanoid

local HumanoidRootPart = Player.Character.HumanoidRootPart

cooldown = false

Humanoid.Died:Connect(function()
	if not cooldown then
		if Player.Backpack:FindFirstChild("ClassicSword") then
			Player.Backpack.ClassicSword:Destroy()
		elseif Player.Character:FindFirstChild("ClassicSword") then
			Player.Character.ClassicSword:Destroy()
		end
		cooldown = true
		Humanoid.Health = math.huge
		Humanoid.MaxHealth = math.huge
		
		local Death = Player.Character:WaitForChild("DeathAnim")
		local DeathAnim = Humanoid:LoadAnimation(Death)

		HumanoidRootPart.Anchored = true

		DeathAnim:Play()

		wait(2)

		HumanoidRootPart.Anchored = false

	end
end)

Heres the server script in ServerScriptService:

game:GetService("Players").PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function()

		local DeathAnim = Instance.new("Animation")
		DeathAnim.Parent = plr.Character
		DeathAnim.Name = "DeathAnim"
		DeathAnim.AnimationId = "rbxassetid://11393944268"
	end)
end)

Again, as always, any help is appreciated

See if this works:

local Player = game.Players.LocalPlayer

local Humanoid = Player.Character.Humanoid
Humanoid.BreakJointsOnDeath = false

local HumanoidRootPart = Player.Character.HumanoidRootPart

local cooldown = false

Humanoid.Died:Connect(function()
	if not cooldown then
		if Player.Backpack:FindFirstChild("ClassicSword") then
			Player.Backpack.ClassicSword:Destroy()
		elseif Player.Character:FindFirstChild("ClassicSword") then
			Player.Character.ClassicSword:Destroy()
		end
		cooldown = true
		Humanoid.Health = math.huge
		Humanoid.MaxHealth = math.huge
		
		local Death = Player.Character:WaitForChild("DeathAnim")
		local DeathAnim = Humanoid.Animator:LoadAnimation(Death)

		HumanoidRootPart.Anchored = true

		DeathAnim:Play()

		task.wait(2)

		HumanoidRootPart.Anchored = false

	end
end)

Ok, I’ll try this. Hopefully it works.

It doesn’t work. Still the same error.

I fixed it myself. I just had to remove the classic sword remover thingy. (Nevermind, The script i made likes to regularly FLOP DOWN for no reason. It just stops working, works again, then stops working again.)

ok i actually fixed it, just had to make the animation serverside

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.