I made a script and animations to have a cooler effect to when your character dies. So far everything works, except the animations. It spawns a fakecharacter to run the animations so it needs a animationcontroller. I pre-inserted one to the pre-prepped "deadchar" and made the script run off of that. When I tested it, the only thing that happened was the character spawning, but there was no animation. Just a NPC sitting there that looks just like me with no output...help?
Script in Workspace:
game.ReplicatedStorage.Death.OnServerEvent:connect(function(plr)
local deadchar = game.ReplicatedStorage.Anim:Clone()
deadchar.Name = plr.Name.." Dying"
deadchar.Parent = workspace
deadchar:MakeJoints()
deadchar.Torso.CFrame = plr.Character.Torso.CFrame
--Apperance for NPC
if plr.Character:FindFirstChild("Shirt") then
plr.Character.Shirt:Clone().Parent = deadchar
end
if plr.Character:FindFirstChild("Pants") then
plr.Character.Pants:Clone().Parent = deadchar
end
for i,v in pairs(plr.Character:GetChildren()) do
if v:IsA("CharacterMesh") then
v:Clone().Parent = deadchar
end
end
for i,v in pairs(plr.Character:GetChildren()) do
if v:IsA("Hat") then
v:Clone().Parent = deadchar
end
if v:IsA("BasePart") then
v.Transparency = 1
end
end
--Animation
local animController = deadchar.AnimControl
animController:LoadAnimation(script.Death):Play()
wait(2)
animController:LoadAnimation(script.Dead):Play()
game.Debris:AddItem(deadchar, 5)
end)

1 comment
I don't think you can play an Animation when you are dead. Same goes for NPCs.