When you want to change how a gui looks for every player, you shouldn't update the StarterGui, otherwise it won't update until they respawn. To make it change automatically, you will have to access the guis via PlayerGui which is inside each player. To do this, you will have to access each player's guis individually using a localscript. You will then need to use a server script to clone the map into the game, otherwise you'd end up crashing the game if each localscript were to do that.
01 | player = game.Players.LocalPlayer |
02 | maintext = player.PlayerGui.Main.Header.MainText |
06 | if game.Players.NumPlayers > 1 then |
07 | maintext.Text = "Deciding what map to play" |
10 | maintext.Text = "Map Chosen: " .. _G.mapChosen.Name |
14 | else maintext.Text = "You need 1 more player" |
This above script should be localscript and placed in the startergui.
01 | map = game.ServerStorage.Maps:GetChildren() |
05 | if game.Players.NumPlayers > 1 then |
07 | ranMap = math.random( 1 , #map) |
08 | _G.mapChosen = map [ ranMap ] |
10 | mapChosenClone = _G.mapChosen:Clone() |
11 | mapChosenClone.Parent = game.Workspace.MapHolder |
This above script should be a server script and placed in Workspace.
This may not entirely work, but this should be helpful.
------------------------
Update: Based on the fact that you posted the whole script now, I have made it so that it should work now as is.
------------------------
003 | map = game.ServerStorage.Maps:GetChildren() |
011 | if game.Players.NumPlayers > 1 then |
012 | for i,v in pairs (game.Players:GetPlayers()) do |
013 | v.PlayerGui.Main.Header.MainText.Text = "Deciding what map to play" |
016 | for i,v in pairs (game.Players:GetPlayers()) do |
017 | v.PlayerGui.Main.Header.MainText.Text = "" |
019 | ranMap = math.random( 1 , #map) |
020 | mapChosen = map [ ranMap ] |
021 | for i,v in pairs (game.Players:GetPlayers()) do |
022 | v.PlayerGui.Main.Header.MainText.Text = "Map Chosen: " .. mapChosen.Name |
025 | for i,v in pairs (game.Players:GetPlayers()) do |
026 | v.PlayerGui.Main.Header.MainText.Text = "" |
028 | mapChosenClone = mapChosen:Clone() |
029 | mapChosenClone.Parent = game.Workspace.MapHolder |
036 | players = game.Players:GetChildren() |
038 | teams = { "Bright red" , "Bright blue" } |
041 | for i,v in pairs (players) do |
042 | v.TeamColor = BrickColor.new(teams [ num ] ) |
054 | bspawn = mapChosenClone.BlueSpawn |
055 | rspawn = mapChosenClone.RedSpawn |
057 | for i,v in pairs (game.Players:GetPlayers()) do |
059 | check = game.Workspace:FindFirstChild(name) |
060 | if v.TeamColor = = BrickColor.new( "Bright red" ) then |
062 | checkHumanoid = check:FindFirstChild( "Humanoid" ) |
063 | if checkHumanoid then |
064 | local distance = math.random(- 4 , 4 ); |
065 | check:MoveTo(rspawn.Position + Vector 3. new(distance, distance, distance)) |
068 | elseif v.TeamColor = = BrickColor.new( "Bright blue" ) then |
070 | checkHumanoid = check:FindFirstChild( "Humanoid" ) |
071 | if checkHumanoid then |
072 | local distance = math.random(- 4 , 4 ); |
073 | check:MoveTo(bspawn.Position + Vector 3. new(distance, distance, distance)) |
085 | game.StarterGui.Main.Header.MainText.Text = "Game begins in: " .. i |
087 | game.StarterGui.Main.Header.MainText.Text = "" |
095 | game.StarterGui.Main.Header.MainText.Text = "Time left: " .. i |
097 | game.StarterGui.Main.Header.MainText.Text = "" |
099 | game.StarterGui.Main.Header.MainText.Text = "The round has ended" |
101 | game.StarterGui.Main.Header.MainText.Text = "" |
107 | for i,v in pairs (game.Players:GetPlayers()) do |
108 | v.Character:MoveTo(Vector 3. new( 108 , 11.19 , - 29 )) |
116 | mapChosenClone:Destroy() |
123 | game.StarterGui.Main.Header.MainText.Text = "You need 1 more player to join" |