Hello all,
I was wondering if anyone knows how to make it so if one player dies, all players die.
Thanks
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!
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!
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.
2 comments
As in any random player or a surtent player?
Yeah, if any player dies in the server.