The issue with the below script is that it teleports one players, and after the Blue player is affected, it teleports another player to the position and so on, how do I edit this script to teleport all players and then affect blue team and red team separately?

local blue = game.ServerStorage.Blue
local red = game.ServerStorage.Red


while true do wait(1)
	if blue.Value >= 100 then
		blue.Value = 0
		red.Value = 0
		game.Workspace:findFirstChild("Map"):Remove()
		mapstorage = game.ServerStorage.Maps:GetChildren()
		maps = mapstorage[math.random(1,#mapstorage)]
		local newmap = maps:Clone()
		newmap.Parent = game.Workspace
		newmap.Name = "Map"
		game.Workspace.Lobby.Music:Play()
		
		for _, player in pairs(game.Players:GetPlayers()) do -- ALL PLAYERS - Mainly this part.
			player.Character:MoveTo(game.Workspace.Resp.Position)
			player.PlayerGui.BlueWin.Frame.Visible = true
			player.PlayerGui.Int.Frame.Visible = true
			
			if player.TeamColor == BrickColor.new("Bright blue") then -- BLUE TEAM ONLY
				local spawnb = game.Workspace.Map.Spawns.Blue
				player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 500
				wait(20)
				player.PlayerGui.Int.Frame.Visible = false
				player.Character:MoveTo(spawnb.Position)
				
			elseif player.TeamColor == BrickColor.new("Bright red") then -- RED TEAM ONLY
				local spawnr = game.Workspace.Map.Spawns.Red
				player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 100
				wait(20)
				player.PlayerGui.Int.Frame.Visible = false
				player.Character:MoveTo(spawnr.Position)
			end
		end
	end
end

1 comment

0

Nevermind this question, it was a problem with placing my ends incorrectly.