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

why does the ragdoll refresh after taking damage?

Asked by 6 years ago
Edited 6 years ago

so when you die you turn into a ragdoll but if your ragdoll takes damage it refreshes for some reason and makes you respawn depending on how many times the ragdoll got hit

script.Setup:Destroy()

game.Players.PlayerAdded:connect(function(pla)
    pla.CharacterAdded:connect(function(cha)
        cha.Humanoid.Died:connect(function()
            local ragdoll = game.ServerStorage.ragdoll:Clone()
            ragdoll.Name = cha.Name
            for _, obj in pairs(cha:GetChildren()) do
                if obj:IsA("Accessory") or obj:IsA("CharacterMesh") or obj:IsA("BodyColors") or obj:IsA("Shirt") or obj:IsA("Pants") then
                    obj:Clone().Parent = ragdoll
                end
            end
            ragdoll.Torso.roblox.Texture = cha.Torso.roblox.Texture
            ragdoll.Head.face.Texture = cha.Head.face.Texture
            ragdoll.Parent = workspace
            wait()
            pla.Character = ragdoll
            wait()
            ragdoll:SetPrimaryPartCFrame(cha.Head.CFrame)
            ragdoll.CamScript.Disabled = false
            wait(5)
            pla:LoadCharacter()
        end)
    end)
end)

setup script is

script.Parent.ragdoll.Parent = game.ServerStorage
script.Parent.Disabled = false

1 answer

Log in to vote
1
Answered by
hellmatic 1523 Moderation Voter
6 years ago
Edited 6 years ago

Put this in StarterPlayerScripts under the StarterPlayer folder.

repeat wait() until game.Players.LocalPlayer
repeat wait() until game.Players.LocalPlayer.Character:IsDescendantOf(workspace)

local cha = game.Players.LocalPlayer.Character
local Humanoid = cha.Humanoid

local IsDead = false 

function onDeath()
    if not IsDead then 
        IsDead = true 
        local ragdoll = game.ServerStorage.ragdoll:Clone()
            ragdoll.Name = cha.Name
            for _, obj in pairs(cha:GetChildren()) do
                if obj:IsA("Accessory") or obj:IsA("CharacterMesh") or obj:IsA("BodyColors") or obj:IsA("Shirt") or obj:IsA("Pants") then
                    obj:Clone().Parent = ragdoll
                end
            end
            ragdoll.Torso.roblox.Texture = cha.Torso.roblox.Texture
            ragdoll.Head.face.Texture = cha.Head.face.Texture
            ragdoll.Parent = workspace
            wait()
            pla.Character = ragdoll
            wait()
            ragdoll:SetPrimaryPartCFrame(cha.Head.CFrame)
            ragdoll.CamScript.Disabled = false
            wait(5)
            pla:LoadCharacter()
    end
end

Humanoid.Died:connect(onDeath)
0
doesnt work for some reason. heres the model https://www.roblox.com/library/515448859/Constraint-Ragdoll User#21615 0 — 6y
Ad

Answer this question