I can’t use the on player added because it is a game handler
I just need it for a small part
local moneyPerWave = 10
for i, v in pairs(alivePlrs) do
if player.Name == v then
player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + moneyPerWave
end
end
end
So you want to reward all the players that are in the table?
If that’s the case then it depends on what you’re storing in the alivePlrs table.
If you are storing the player object you should do
local moneyPerWave = 10
for i, v in pairs(alivePlrs) do
v.leaderstats.Cash.Value = v.leaderstats.Cash.Value + moneyPerWave
end
If you are storing the name of the players then you need to do
local moneyPerWave = 10
for i, v in pairs(alivePlrs) do
game.Players[v].leaderstats.Cash.Value = game.Players[v].leaderstats.Cash.Value + moneyPerWave
end
This might sound more complicated to you, but you can use module scripts to store the table of alive players and use functions that the server can use to award players.
Like the server script could access the module script by using for i, v in pairs loop.
Like do for i,v in pairs(game:WaitForChild(“Players”):GetChildren())
moduleName.awardMoney(v)
Then in the module check if they are alive within the table and award money if they were alive during the round.