Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

why does the ragdoll refresh after taking damage?

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

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)

1 comment

0

doesnt work for some reason. heres the model https://www.roblox.com/library/515448859/Constraint-Ragdoll

This discussion is preserved as it was. New answers, comments, and votes are closed.