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

How would you prevent joints from breaking when player dies?

Could anyone tell me how I could prevent the player's limbs from falling off when the player dies?

2 comments

0

You mean like a ragdoll?

0

Use welds or motors? We don't actually know what you want here..

1 answer

✓ Accepted answer

You may want to use a fake health system. Allow me to explain.

The first thing you want to do is make a variable inside the player called PHealthor whatever you want to call it. I'm going to use PHealth for this example.

We can add it like so. (script inside workspace or serverscriptservice)

game.Players.PlayerAdded:connect(function(plr)

H=Instance.new("IntValue",plr)
H.Name="PHealth"
H.Value=100
end)

So now we have a health variable inside the player with a value of 100.

Next, we'll need to add the character's death activator. (inside a LocalScript in StarterPack)

wait(.01)

while wait() do

if game.Players.LocalPlayer.PHealth.Value<1 then

 game.Players.LocalPlayer.PHealth.Value=100

--do the code that activates when a player dies here.

end

--and here we'll set MaxHealth.

if game.Players.LocalPlayer.PHealth.Value>100 then
game.Players.LocalPlayer.PHealth.Value=100

end

end

Now we don't want the player resetting via the menu, right? We can fix this by renamingHumanoid in the player. Now we can add this as an updated version of the above script.

wait(.01)

game.Players.LocalPlayer.Character:WaitForChild("Humanoid").Name="MyHumanoid"

while wait() do

if game.Players.LocalPlayer.PHealth.Value<1 then

 game.Players.LocalPlayer.PHealth.Value=100

--do the code that activates when a player dies here.

end

--and here we'll set MaxHealth.

if game.Players.LocalPlayer.PHealth.Value>100 then
game.Players.LocalPlayer.PHealth.Value=100

end

end

Lastly, here's a sample script of a part that will kill the player. Though the player is unafected if he/she has a forcefield.


script.Parent.Touched:connect(function(hit)

if hit.Parent:findFirstChild("MyHumanoid") and not hit.Parent:findFirstChild("ForceField") then

game.Players:GetPlayerFromCharacter(hit.Parent).PHealth.Value=0

end

end)

I hope this little explanation helped you out! If you liked it, hit that accept button!

PS: Please attempt you own code before coming here. If you did, post your code so we can fix it.

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