So some brief explaining for what I'm doing:
I'm trying to make a sword dueling system between players for a game I'm working on for a friend.
I have it set up as follows:
Match values are kept in a folder in replicated storage. There, folders for each team and values for each player in each team are kept and updated as the match progresses.
When a player dies, the server runs a function that gives a "dead" value in the player value, then the function that is supposed to update the match runs. The first part of this checks if any teams have died, and removes the dead teams from a table.
To simplify, whenever a player dies, the match is updated through the server.
local teams = _match:GetTeamsFromMatch(match) -- returns array of teams for index, team in next, teams do if _match:CheckIfTeamHasDied(team) then print ("Team has died") table.remove(teams, index) end end
If one team is left, then that team gets a "Win" for that round of the match until one team has reached maximum wins, then the round is over. Similar to Auto Duels.
if #teams == 1 or #teams == 0 then if #teams == 1 then print ("one team left") teams[1].Wins.Value = teams[1].Wins.Value + 1 if teams[1].Wins.Value == match.Configuration.PlayTo.Value then _match:End(match, "Round has ended. A team won!") return end end -- some code below this to reset the map and start a new round. Isn't important for the problem, though. end
The problem I'm having is that when players tie both players get a win. This can cause several issues, as you can imagine.
If both players die at the exact same time, the server runs an update for both. How can I determine if there is a tie or not between players, and then only update for one team win?