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