Hello all,
I was wondering if anyone knows how to make it so if one player dies, all players die.
Thanks
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:
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!