I just wrote a new script that is basically an entire game's basic round functioning, but it won't even start to function from the beginning. When I join the game, it won't update my Gui, and I'm not sure why. Here's my code:
while true do --begin loop
IntermissionTime = 30
a = game.Players:GetChildren()
x = 4 - #a
if #a < 4 then --check for numplayers
for i,v in pairs(a) do
v.PlayerGui.ScreenGui.Frame.RoundTime.Text = x.." more players are needed to start the round."
end
elseif #a >= 4 then
repeat --intermission timer run
wait(1)
for i,v in pairs(a) do --change playergui intermission text
IntermissionTime = IntermissionTime - 1
player.PlayerGui.ScreenGui.Frame.RoundTime.Text = "Intermission: "..IntermissionTime
end
until
IntermissionTime == 0
end
if IntermissionTime == 0 then --begin round
for i,v in pairs(a) do --change playergui text to round beginning
a.PlayerGui.ScreenGui.Frame.RoundTime.Text = "Round beginning!"
end
wait(5)
-- randomly choose 1 player
local players = {game.Players:GetChildren()}
local randomPlayer = math.random(1,#players)
randomPlayer.TeamColor = BrickColor.new("Bright red")
m = Instance.new("Message")
m.Parent = game.Workspace
m.Text = randomPlayer.." is the Juggernaut this round."
wait(5)
m:Destroy()
-- spawn random map
maps = {Map1, Map2, Map3, Map4, Map5}
randomMap = math.random(1,#maps)
clone = game.Lighting..randomMap:clone()
clone.Parent = game.Workspace
-- delete lobby spawnlocations
spawns = game.Workspace.Lobby:GetChildren()
for i,v in pairs(spawns) do --reparent spawnlocations
if v:IsA("SpawnLocation") then
v.Parent = game.Lighting
end
end
--spawn players
for i,v in pairs(a) do --kill players
v.Character:WaitForChild("Humanoid").Health = 0
end
--begin round timer
RoundTime = 300
repeat
wait(1)
for i,v in pairs(a) do
RoundTime = RoundTime - 1
a.PlayerGui.ScreenGui.Frame.RoundTime.Text = "Time Left: "..RoundTime
end
until
RoundTime == 0
if Roundtime == 0 then --round end
for i,v in pairs(a) do --change playergui
v.PlayerGui.ScreenGui.Frame.RoundTime.Text = "Round over!"
end
for i,v in pairs(game.Lighting:GetChildren()) do --reassign spawnlocation parents to workspace
if v:IsA("SpawnLocation") then
v.Parent = game.Workspace
end
end
for i,v in pairs(game.Workspace:GetChildren()) do --destroy map
if v.Name == "Map%d" then
v:Destroy()
end
end
for i,v in pairs(a) do
v.Character:WaitForChild("Humanoid").Health = 0
end
end --end roundend if statement
end --end round begin
end --end loop
