how could I check who wins a round?
Asked by
4 years ago Edited 4 years ago
I have a leaderstats value called "Banked". Players on a team bank their coins, and when both teams have banked, whichever team has the most coins banked wins the round. How could I do this?
This is my current attempt, but the team that banked their coins last will always show as 0 coins banked.
01 | for i, v in pairs (Players:GetPlayers()) do |
02 | if v.Team = = Teams.Blue then |
03 | totals [ 1 ] = totals [ 1 ] + v.leaderstats.Banked.Value |
04 | elseif v.Team = = Teams.Red then |
05 | totals [ 2 ] = totals [ 2 ] + v.leaderstats.Banked.Value |
08 | v.Team = Teams.Waiting |
09 | v.leaderstats.Coins.Value = 0 |
11 | if totals [ 1 ] > totals [ 2 ] then |
13 | showNotification:FireAllClients( "Blue won!" , Color 3. new( 0 , 0 , 1 ), 5 ) |
14 | elseif totals [ 2 ] > totals [ 1 ] then |
16 | showNotification:FireAllClients( "Red won!" , Color 3. new( 0.870588 , 0 , 0 ), 5 ) |
19 | showNotification:FireAllClients( "Tie!" , Color 3. new( 0 , 0 , 0 ), 5 ) |