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

Hello Developers! Im making a Zombie Rush type game that spawns zombies however I want to give rewards to players who have survived that round. However my script which has the players in a round is different from the script which spanws the zombies and handles the waves.
So how can I make one of my scripts give rewards to players that are still in the match after a wave has been completed?

Here is my script which handles the players in the round:

And here is my script which handles the waves and spawns zombies:

If anyone can help me it will be highly appreciated!

I dont know how to do this script. I have tried multiple ways but it doesnt work. If anyone can help me it will be highly appreciated!

Maybe you can try making a table for survivors. put all of the players in it when round starts and remove the players that die. Reward everyone in the table when round finishes

Have you read the player script? It already makes a table but how can I make the script which handles the waves know which players to reward and which not?

Dont reward the players trough the wave script, reward them with the player script

Ok but how can the player script know when the wave script has started a new wave?

Try using remote event to do that.

Not a remote event you have to use a bindable event but. How can I implement this into my script without breaking it. Ive tried using events but I havent put them in the right place so it breaks the script. Do you know what the right place to put is?

Create a new script that does the table thing

Huh? No why I already have a script which does the table thing. I am not changing that.

Ummmmmm, I will think of something.

Ok thankyou my game is coming out tommorow so I really need this.

Have you read the scripts? I already do that but remember there are 2 scripts. 1 handles the players and 1 handles the waves. Please read the scripts.

Sorry, but I cant think that fast, Iā€™m currently trying to find something. Iā€™m not a supercomputer.

Yes I know but a pro programmer should easily be able to do this. But dont worry take your time and do it right.

And are you sure that links are valid? I cant open them Its probably that my internet is really bad (it has been like this for a while)

Uh yes I can open them in a split second. I can provide the scripts in devforum if you want to.

The player script:

-- Define variables

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local ServerStorage = game:GetService("ServerStorage")

local MapsFolder = ServerStorage:WaitForChild("Maps")

local Status = ReplicatedStorage:WaitForChild("Status")

local GameLength = 360

local reward = 1

local cash = math.random(1200,3000)

local event = game.ReplicatedStorage.Event


 





-- Game loop

while true do
	
	Status.Value = "Waiting for enough players to start"
	
	repeat wait() until game.Players.NumPlayers >= 2
	
	Status.Value = "Intermission"
	
	wait(20)
	
	local plrs = {}
	
	for i, player in pairs(game.Players:GetPlayers()) do
		if player then
			table.insert(plrs,player) -- Add each player into plrs table
		end
	end
	
	local AvailableMaps = MapsFolder:GetChildren()

	local ChosenMap = AvailableMaps[math.random(1,#AvailableMaps)]
	
	Status.Value = ChosenMap.Name.." is the chosen Map"
	
	local ClonedMap = ChosenMap:Clone()
	ClonedMap.Parent = workspace
	
	-- Teleport players to the map
	Status.Value = "Preparing Arena"
	wait (5)
	local SpawnPoints = ClonedMap:FindFirstChild("SpawnPoints")
	
	if not SpawnPoints then
		print("Spawnpoints not found!")		
	end
	
	local AvailableSpawnPoints = SpawnPoints:GetChildren()
	 
	
	
	for i, player in pairs(plrs) do
		if player then
			character = player.Character
			
			if character then
				
				-- Teleport them
				
				character:FindFirstChild("HumanoidRootPart").CFrame = AvailableSpawnPoints[1].CFrame + Vector3.new(0,10,0)
				table.remove(AvailableSpawnPoints,1)
				
				
				
				-- Give them a sword and a revolver
				local equipped = game.ServerStorage.PlayerData[player.Name].Equipped
				
				if equipped.Value ~= "" then
					local weapon = game.ServerStorage.Items[equipped.Value]:Clone()
					weapon.Parent = player.Backpack
				else
					local Knife = ServerStorage.Pistol:Clone()
					    Knife.Parent = player:WaitForChild("Backpack")
				end
				
			
				                    
				

				
				local GameTag = Instance.new("BoolValue")
				GameTag.Name = "GameTag"
				GameTag.Parent = player.Character
				
			else
				-- There is no character
				if not player then
					table.remove(plrs,i)
				end
			end
		end
	end
	

	event:Fire()
				print ("EventFired")
	
	
	for i = GameLength,0,-1 do
		
		for x, player in pairs(plrs) do
			if player then
				
				character = player.Character
				
				if not character then
					-- Left the game
					table.remove(plrs,x)
				else
					if character:FindFirstChild("GameTag") then
						-- They are still alive
						print(player.Name.." is still in the game!")
					else
						-- They are dead
						table.remove(plrs,x)
						print(player.Name.." has been removed!")
					end
				end
			else
				table.remove(plrs,x)
				print(player.Name.." has been removed!")
			end
		end
		    
		
		
		Status.Value = "There are "..i.." seconds remaining, and "..#plrs.." players left"
		
		
		
		if #plrs == 0 then
			Status.Value = "Monsters have defeated you!"
		end
		
		
		wait(1)
	end
	
	print("End of game")
	
	wait(2)
	
	for i, player in pairs(game.Players:GetPlayers()) do
		character = player.Character
		
		if not character then
			-- Ignore them
		else
			if character:FindFirstChild("GameTag") then
				character.GameTag:Destroy()
			end
			
			for _, tool in pairs(player.Backpack:GetChildren()) do
				if tool:FindFirstChild("Price") then
					tool:Destroy()
				end
			end
			
			for _, tool in pairs(character:GetChildren()) do
				if tool:FindFirstChild("Price") then
					tool:Destroy()
				end
			end
			
		end
		
		player:LoadCharacter()
	end
	
	
	
	ClonedMap:Destroy()
	
	Status.Value = "Game ended"
	
	wait(2)
end

That would be good, my internet is currently really bad :confused:

The wave script:

local event = game.ReplicatedStorage.Event
local Waves = game.ServerStorage.Waves
local Players = game.Players:GetChildren()


local function onEvent()
wait (0.5)
local Wave1 = Waves.Wave1:Clone()
wait (0.5)
Wave1.Parent = game.workspace
repeat 
wait(0.5) 
until game.Workspace.Wave1.Monsters.Value == 0 
Players:Findfirstchild("leaderstats").Coins = Players:Findfirstchild("leaderstats").Coins + 10
game.Workspace.Wave1:Destroy()
local Wave2 = Waves.Wave2:clone()
Wave2.Parent = game.workspace
repeat 
wait(0.5) 
until game.Workspace.Wave2.Monsters.Value == 0 
Players:Findfirstchild("leaderstats").Coins = Players:Findfirstchild("leaderstats").Coins + 10
game.Workspace.Wave2:Destroy()
	local Wave3 = Waves.Wave3:clone()
script.Parent.Wave = 3
Wave3.Parent = game.workspace
repeat 
wait(0.5) 
until game.Workspace.Wave3.Monsters.Value == 0 
game.Workspace.Wave3:Destroy()
	local Wave4 = Waves.Wave4:clone()
script.Parent.Wave = 4
Wave4.Parent = game.workspace
repeat 
wait(0.5) 
until game.Workspace.Wave4.Monsters.Value == 0 
game.Workspace.Wave4:Destroy()
	local Wave5 = Waves.Wave5:clone()
script.Parent.Wave = 5
Wave5.Parent = game.workspace
repeat 
wait(0.5) 
until game.Workspace.Wave5.Monsters.Value == 0 
game.Workspace.Wave5:Destroy()
	local Wave6 = Waves.Wave6:clone()
script.Parent.Wave = 6
Wave6.Parent = game.workspace
repeat 
wait(0.5) 
until game.Workspace.Wave6.Monsters.Value == 0 
game.Workspace.Wave6:Destroy()
	local Wave7 = Waves.Wave7:clone()
script.Parent.Wave = 7
Wave7.Parent = game.workspace
repeat 
wait(0.5) 
until game.Workspace.Wave.Monsters.Value == 0 
game.Workspace.Wave7:Destroy()
	local Wave8 = Waves.Wave8:clone()
script.Parent.Wave = 8
Wave8.Parent = game.workspace
repeat 
wait(0.5) 
until game.Workspace.Wave8.Monsters.Value == 0 
game.Workspace.Wave8:Destroy()
	local Wave9 = Waves.Wave9:clone()
script.Parent.Wave = 9
Wave9.Parent = game.workspace
repeat 
wait(0.5) 
until game.Workspace.Wave9.Monsters.Value == 0 
game.Workspace.Wave9:Destroy()
local Wave10 = Waves.Wave:clone()
script.Parent.Wave = 10
Wave10.Parent = game.workspace
repeat 
wait(0.5) 
until game.Workspace.Wave10.Monsters.Value == 0 
game.Workspace.Wave10:Destroy()
script.Parent.Wave = 0




	

end

event.Event:Connect(onEvent)