Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Animation Death not doing anything?

Asked by 9 years ago

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)

0
I don't think you can play an Animation when you are dead. Same goes for NPCs. EzraNehemiah_TF2 3552 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago
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)

0
AnimControl is inside the NPC. And it is a animation playing. And the character is inside ReplicatedStorage. NO ERRORS! Just a crash or no animation. And yes you can play animations on NPCs. I read this a loooong time ago: http://wiki.roblox.com/index.php?title=Animations#Playing_Animation_in_Non-Player_Character lightpower26 399 — 9y
Ad

Answer this question