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.
im having trouble with the checking of death and round progression.
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.
-- 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:
Check which player is alive (true)
reset the table
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