How would i go about making a tournament system?

local function fight(team1,team2,dead1,dead2)
for i, v in pairs(team1) do 
	v.Character:MoveTo(FighterSpawns[math.random(1,#FighterSpawns)].Position)
	v.string.Changed:Connect(function(arg)
		print("a")
		if arg =="Value"  then 
			print("playerKilled by " .. v.string.Value)
			table.remove(dead1,1)
			if #dead1 == 0 then
				table.insert(progressed,1,team2)
			end
		end
	end)
end
for i, v in pairs(team2) do 
	v.Character:MoveTo(FighterSpawns[math.random(1,#FighterSpawns)].Position)
	v.string.Changed:Connect(function(arg)
		print("a")
		if arg =="Value" then 
			print("playerKilled by " .. v.string.Value)
			table.remove(dead2,1)
			if #dead2 == 0 then
				table.insert(progressed,1,team1)
			end
		end
	end)
end

this is what i currently have, the goal is to have to players fight and then add the winner to a table to progress to the next round, it checks when the player has been killed through a value that ive linked to my weapon system.

image

im having trouble with the checking of death and round progression.

Any help would be appreciated!

1 Like

Please define what the i and v are here. However, if the problem is what I think it is, couldn’t you just use :getpropertychangedsignal for the players health?

im not really asking anyone to fix any bugs in particular, im just wondering if anyone has an idea on how i should proceed from the code previously mentioned.

the code above takes two teams from a sorting function and then checks for the players deaths, from there i am stuck.

Well, first you need to make a table.

-- This table should be formatted like this: ["PlayerName"] = AliveBool (true or false)
local current_players = {}

when a player joins the tournament, add them to this table and set them to true. When they die, set them to false, and every time someone dies, run a function to:

  1. Check which player is alive (true)
  2. reset the table
  3. proceed to the next round

You may have to set everyone who is not playing to false before you start a round, to prevent people who are not currently playing from winning

1 Like

thank you, i was using tables but did not think of this method, ill try it out and get back to you!