function startgame() wait() if game.Players.NumPlayers >= 1 then for _, player in pairs(game.Players:GetPlayers()) do local message = player.PlayerGui.ScreenGui.TextLabel message.Text = "Getting The Game Ready" wait(3) local model = game.Lighting.Maps local map = model:GetChildren()[math.random(1, #model:GetChildren())] message.Text = (map.Name) wait(2) startgame() end end end startgame()
I don't know why this doesnt work in Server.
Hope you can help, Thanks!
function startgame() wait() if game.Players.NumPlayers >= 1 then for _, player in pairs(game.Players:GetPlayers()) do local message = player.PlayerGui.ScreenGui.TextLabel message.Text = "Getting The Game Ready" wait(3) local model = game.Lighting.Maps local map = model:GetChildren()[math.random(1, #model:GetChildren())] message.Text = (map.Name) wait(2) startgame() end end end repeat wait() until game.Players.NumPlayers >= 1 startgame()
What's happening here is that when you run the function startgame(), it checks, and there is no players. Then nothing. nothing happens. So what we should do is repeat waiting until the number of players is greater then 0, then run the function for the first time.