Only some scripts inside my loop work

So, I’m working on a game loop, and it works fine, till a point. All my scripts inside the loop function fine but when I put them inside a loop it doesn’t seem to work.

Here is my script:
—local winreward = 1
local pointsreward = 100
local Status = game.StarterGui.StatusGUI.StatusLabel.StatusText
local PublicInformation = game.StarterGui.InformationGUI.PublicParent.PublicFrame.PublicLabel

while true do
Status.Text = (“You need 4 players to start!”)
repeat wait(1) until
#game.Players:GetPlayers() >= 1

Status.Text = ("Intermission")
game.StarterPlayer.CharacterWalkSpeed = 0
game.StarterPlayer.CharacterJumpPower = 0
print("Round starting")

local plrs = {}

for i, player in pairs(game.Players:GetPlayers()) do
	if player then
		table.insert(plrs,player)
	end
end

print("Players table has been created")
wait(2)

Status.Text = ("Introduction")

local AirportSpawn = workspace.Airport:FindFirstChild("AirportSpawnPoints")

local AvailableAirportSpawns = AirportSpawn:GetChildren()

for i, player in pairs(plrs) do 
	if player then
		character = player.Character
		
		if character then
			---teleport player
			character:FindFirstChild("HumanoidRootPart").CFrame = AvailableAirportSpawns[1].CFrame
			table.remove(AvailableAirportSpawns, 1)
		else
			---player left/ragequited
			if not player then
				table.remove(plrs, i)
			end	
		end
	end	
end


print("Players have been moved to a spawn") ---only the prints work after this point, but scripts work fine if i remove them from the loop
			
game.StarterGui.InformationGUI.PublicParent.Visible = true
PublicInformation.Text = ("Welcome to PlanetQuest!")
wait(3)
PublicInformation.Text = ("In this competition, we will travel the world, and complete different challenges.")
wait(4)
PublicInformation.Text = ("The last team to arrive will be eliminated.")
wait(3)
PublicInformation.Text = ("Now, before we start, we need to sort you into teams.")
wait(3)
	
print("Introduction: Part 1")
			
					
local spawns = game.Workspace.Airport.AirportSpawnPoints:GetChildren()
		
for i, spawn in pairs(spawns) do
  spawn.AllowTeamChangeOnTouch = true
end
wait(0.5)
		
local spawns = game.Workspace.Airport.AirportSpawnPoints:GetChildren()
		
for _, spawn in pairs(spawns) do
  spawn.AllowTeamChangeOnTouch = false
end
print("Introduction: Part 2")
	
PublicInformation.Text = ("Now, that we are ready, lets begin PlanetQuest!")
wait(3)
PublicInformation.Text = ("Ready.....")
wait(1.5)
PublicInformation.Text = ("GO!!!")

game.StarterPlayer.CharacterJumpPower = 50
game.StarterPlayer.CharacterWalkSpeed = 16

print("Competition starting")	

end

I’m very new to scripting, so if I made any mistake, could you please let me know. Thanks!

1 Like

You shouldn’t change the GUI’s in the StarterGui as they are replicated to the client. You can access the client’s GUI via PlayerGui.