How can I only reward players in the match using another script?

So in the wave script I have tried to do it but it doesnt work and even if it does it would give it to all players which is not what I want.

I found it! (Maybe). Fire a event when round finishes and on the player script when the event is fired give cash to players that are on the table. Maybe this will work?

It will but how can I implement this into my script. I would like you to answer with script which will enable this but not break anything else.

Ok, working on it now. I will send the script.

Thank you so much! It will be extremely helpful. Because im on a tight deadline.

Uhm, I guess you can add two teams, one survivors and spectators, when the survivors die, they get teleported to the pad that changes them into spectators, then add a script that rewards survivors when the round ends, or just add a wait function for a certaina mount of time.

It depends on where you want to award the players. If you want to award them in the wave script than you need to use one bindable event to send the players from the main script every wave. And award the players at the end of each wave. But, if you are awarding them from the main script than you need to use two bindable to send the players back and forth at the beginning and end of the wave.

Ok the first one might work. Do I do it like this?
Main Script:

event:fire(#plrs)

My main script already does that. However what do I put into my wave script to award these players.

Do I put

plrs.leaderstats.Coins = plrs.leaderstats.Coins + 100

?

You can have a folder in replicated storage with string values and set the values of those string values to the player that survived and in the reward code you can do this:

local folder = game.ReplicatedStorage.Folder -- folder 

for _, Player in pairs(folder:GetChildren()) do -- goes through the folder
	if Player:IsA("StringValue") then -- if it finds a string value 
		local plr = game.Players:FindFirstChild(Player).Value -- finds the player
		plr.leaderstats.Currency.Value = plr.leaderstats.Currency.Value + 100  -- awards the player
	end
end

Thankyou for that. But I have already found a way to do this.

Im gonna see if it works.

Ok you can also use this code to add the players to the folder

local folder = game.ReplicatedStorage.Folder -- folder

local survivedPLRs = {}

for _, Player in pairs(survivedPLRs) do -- goes through the folder

    local plrString = Instance.new("StringValue")

     plrString.Value = Player

     plrString.Parent = folder

end

Im happy to see that you managed to do it. I was writing the script but if you found it Im not continuing.

Ok I will try this. But what line should I put this on?

Are you checking for surviving players? Sorry I don’t really understand too much of the game concept. If you are checking for surviving players and players who die in a round I see your script already adds a game tag so maybe remove the tag? Sorry I don’t really understand what you are trying to write in your script but if players die you can just remove the tag and check which players still have the tag to give rewards. Of course this is assuming your game tag does nothing else other than just indicate a player is in the game.

What? Which line in the main script do I put this on?

function AwardPlayers(plrs,Amount)
	for i,plr in ipairs(plrs) do
		plr:FindFirstChild('leaderstats').Coins.Value = plr:FindFirstChild('leaderstats').Coins.Value + Amount
	end	
end

This is all I want to know.

You can really put it in any line. Just you need something to call it. Also define plrs and the amount.

plrs and amount is already defined. I can put this in any line of my main script? I think Its better to use while true do.

Uhh no you need a check. for example you need to define said player like I want to give this person a reward amount. so you would write their player object. because it loops through their player object and adds the value to the coin value. If you have a table you can loop through it like for i,v in pairs(table) do
AwardPlayers(v,–Amount here.)
end

yes so it is already defined: Amount will be 100 for example, and plrs is already in there. I just need to put a while true do to define plrs in the other script.