[Solved!] How would I make the Map get Destroyed after all players Die?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    Map gets destroyed and a new round starts once all players die.

  2. What is the issue? Include screenshots / videos if possible!
    Can’t figure it out.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve tried to add a 1 to a value everytime a player dies and Destroy the map after it reaches a certain value.

local MapsFolder = game:GetService("ServerStorage").Maps
local Maps = MapsFolder:GetChildren()
local IntermissionTime = script.IntermissionTime
local Message = Instance.new("Hint")

while true do
	local ChosenMap = Maps[math.random(1, #Maps)]
	local MapClone = ChosenMap:Clone()
	
	Message.Parent = workspace
	Message.Text = "Intermission"
	
	task.wait(IntermissionTime.Value)
	
	Message.Parent = game:GetService("ServerStorage")
	
	Message.Parent = workspace
	Message.Text = "Map Chosen: "..ChosenMap.Name
	
	task.wait(5)
	
	Message.Parent = game:GetService("ServerStorage")
	
	MapClone.Parent = game:GetService("Workspace")
	MapClone:MakeJoints()
end

Put in-round players in a team or give them a boolvalue, and you can check from there if there’s nobody in the living team/nobody has the in-round value:

if #team:GetPlayers() == 0 then
 print("nobody is alive")
end
1 Like

How exactly are you going to determine the amount of in-game players (not spectators)? If you want to check from team, you can use Team:GetPlayers()

Make a table of every player in the server, this for example should be the values of every player in the table:

local AlivePlayersInTeam = {
["Snowxy0x"] = true;
}

When a player dies on the team, you can use table.remove to remove them from the table of alive players on that team.

Then, do something like this to detect if the team has 0 players left alive on the team.

if #AlivePlayersInTeam == 0 then -- the # means amount

end
1 Like