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)
game.ReplicatedStorage.Death.OnServerEvent:connect(function(plr) local deadchar = game.ReplicatedStorage.Anim:Clone()--Is Anim a character built in your script? Is It in ReplicatedStorage? deadchar.Name = plr.Name.." Dying" deadchar.Parent = workspace--I believe if you place it in workspace the Animation should work such as the characters arms and legs move a bit if u use C0 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--Now carefully examine your code here what is "AnimControl" where as in it isn't defined anywhere in your script. animController:LoadAnimation(script.Death):Play()--Your animation is a sound? Or is it just a for I loop controlling the animations of the C0? wait(2) animController:LoadAnimation(script.Dead):Play() game.Debris:AddItem(deadchar, 5) end)