How to make a round system when 1 player died(but not leaves) the whole entire game reset?

Hello, the thing I want help with might be a little confusing on why I would want that. It has something to do with an obby, and teamwork. If a player dies the whole obby restarts, but if they all make it the game restarts. They have about 7 minutes to complete it.

I just don’t know how to do it, and I really hope to get what I want, this project I’m making is fun and I want to complete it.

I did try fighting some answers, but there was not something I wanted. Thank you!

Do you have a script that you’ve been working on for this?

No, I dont have a script like I said I didn’t know how to do it.

You can use a value and set it to true when the obby/game is on. And if a player dies, the script can check if the value is true. If the value is true, the entire game resets.

You can store this value somewhere in the workspace as it should be in the server, and not in the client of the game.

Let me know if you still need help or more detail! :slight_smile:

Your game sounds interesting and I’d like to play it.

So how can you do it? Well, loop through the player list and use Humanoid.Died to check if the player died. If any player dies during the round, end the round.

1 Like

Here is a script:


for _, player in pairs(game.Players:GetService("Players"):GetPlayers() do
player.Character.Humanoid.Died:Connect(function()
-- reset the obby
end)
end

If you’re using the value like I said, just set it to true when the game starts and input it inside the script attached. Once the game ends, just set it to false. Make sure it is a server script.

Thanks @bitsNbytez

1 Like

Im going to check it out right now, I actually also had the for loop part to kill the players, but didn’t know it would work! (for something else though)

1 Like

You’re welcome! Instead of using a value such as a BoolValue, create a variable called isGameRunning instead and set it to true when the round is in progress.

2 Likes

I also might be here tomorrow, to get someone to test it with me so thank you!

1 Like

I made simple round system. I don’t know if that’s what you meant.

I hope that will help you.

-- Example Code --

local t = 1 -- time 
local gameStopped = false -- this variable is needed, because we will checking if round is still running or not
local MaxRoundTime = 60 -- Your round time (default: 1 minute)

function StopRound()
	-- code to reset round 
	print("Round stopped!")
end

function onCharacterAdded(char)
	local humanoid = char:WaitForChild("Humanoid") -- waiting for humanoid to load 
	
	if not humanoid then return end -- if humanoid doesn't existed then stop all script 
	
	repeat
		print(t) 
		t = t + 1
		wait(1)
		humanoid.Died:Connect(function() -- fires when player dies 
			gameStopped = true 
			StopRound() -- calling function with code to reset round
			t = MaxRoundTime -- basically breaking loop 
		end)
		
	until t == MaxRoundTime
	
	if not gameStopped then -- checking if game wasn't stop when player dies 
		StopRound() -- calling function again 
	end
	
	-- reseting game 
	gameStopped = false
	t = 1
end

function onPlayerAdded(player)
	player.CharacterAdded:Connect(onCharacterAdded) -- getting character
end

game.Players.PlayerAdded:Connect(onPlayerAdded) -- getting player
2 Likes

I know I said ill be here tomorrow, but this really worked and helped me out too. Thank toy so much! I just added part I need into what happened, again thanks! :smiley: