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

respawn all players if one dies?

Hello all,

I was wondering if anyone knows how to make it so if one player dies, all players die.

Thanks

2 comments

0

As in any random player or a surtent player?

0

Yeah, if any player dies in the server.

1 answer

✓ Accepted answer

Hello Helloimpets,

My name is The_Pumpkin President (formerly ZakOMGmcpe564) and I'd be happy to help you with your problem.

You're going to want to insert a couple things:

  • A remote event in Replicated Storage
  • A localscript in StarterGUI
  • A serverscript in ServerScriptStorage

Call the remote event "KillEvent." In said localscript, type in this code.

local plr = game.Players.LocalPlayer
local humanoid = plr.Character.Humanoid

humanoid.Died:Connect(function() -- When the player dies. This applies to everyone in the server.
 game.ReplicatedStorage.KillEvent:FireServer()
end)

Then, in the server script you put in ServerScriptStorage, type this code:

game.Replicated.OnServerEvent:Connect(function()
 local plrs = game.Players:GetChildren() - This gets all the players currently in the game.
 for i = 1,#plrs do
   plrs[i]:LoadCharacter() -- Loads the player's characters. They will generally spawn on SpawnLocations, althouigh if there is none they will spawn at X: 0, Z:0.
 end
end)

Please reply to this answer is you're facing any issues.

Hope this helps!

2 comments

0

Thank you very much, you wouldnt happen to know how to implement it so it tells you who killed the person. If not, dont worry about it. Again, thank you alot!

0

I think I might, but it'll have to wait a little bit as I'm a bit busy ATM. And you're very welcome and I wish your game the best!

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