I want to improve upon my admittedly flawed reward system after a match ends. Currently it rewards good for people who are still alive and won (and also moderately for alive and lost–I digress), but what about the people who won and died? I have it set to where when a player dies they no longer are apart of their team and so they earn low amounts and this along with the fact that people can join a server with a match in progress and still earn rewards are both flaws.
I want to make it better–to where I ignore any new people joining i.e. make a table of current actual players at the start of the match, and then when the round ends, determine their current team (which assuming they have died they will be apart of “Lobby” Team AND are on the list I can determine what rewards would be given)
But I’m not sure how to properly store a player, their team, and clear the table. (Also would there be any bugs if a player leaves? It could result in a nil value if I do it this way)
Sample code:
for _,player in pairs (game.Players:GetPlayers()) do
if (win condition for team1) then
if player.Team==team1 then
GiveMoney:FireClient(100, player)
GiveXP:FireClient(100, player)
end
if player.Team==team2 then
GiveMoney:FireClient(60, player)
GiveXP:FireClient(50, player)
end
else
GiveMoney:FireClient(30, player)
GiveXP:FireClient(25, player)
end