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

Is there a way to prevent characters from breaking upon death?

I've been wondering for along time and never really found out how to do this.

Im not asking for a script, just for a step in the right direction, thank you.

3 answers

A simpler way of wfvj014's solution would be a loop.

My appologies, I incorrectly connected the "Died" event.

game.Players.PlayerAdded:connect(function(plr)
	local A = game.Workspace:WaitForChild(plr.Name):GetChildren()
    game.Workspace:WaitForChild(plr.Name).Humanoid.Died:connect(function()
		for i,v in pairs(A) do
		    if v:IsA("BasePart") then
				v.Anchored = true
			end
		end
    end)
end)

1 comment

0

Use Local Variables. You would have to, you're in a function. Also local variables are almost always better.

I'll provide a way of doing this.

Just anchor the player's parts on death

To do this, use a Died Event. When A player dies, anchor their parts.

Here's an example,

--in a regular script in ServerScriptService
game.Players.PlayerAdded:Connect(function(plr)
	plr.Died:connect(function()
		plr.Character:FindFirstChild("LeftLeg").Anchored = true
		plr.Character:FindFirstChild("RightLeg").Anchored = true
		plr.Character:FindFirstChild("Torso").Anchored = true
		plr.Character:FindFirstChild("Head").Anchored = true
		plr.Character:FindFirstChild("LeftArm").Anchored = true
		plr.Character:FindFirstChild("RightArm").Anchored = true
	end)
end)

You could go through all of the parts and anchor them but I didn't feel like it.

There may be better solutions, this is just my solution.

Good Luck

1 comment

0

Nice solution, but there are a few things I would like to point out: plr.Died is not an event. However, plr.Character.Humanoid.Died is an event. Also, the anchoring part is overcomplicated. He could just use a for i,v in pairs loop to get all the baseparts in the character. else than that, nice thought ;)

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