I made a script that's supposed to teleport players to a location AFTER there are at least two players in the server. The script is a local script inside StarterPack. The code is below.
if #Players:GetChildren() <2 then local m = Instance.new("Message", game.Workspace) m.Text = "There must be 2 or more players in the server." if #game.Players:GetPlayers() >=2 then m:Destroy() end end repeat wait() until #game.Players:GetPlayers() >2 target = CFrame.new(0, 5, -100) --could be near a brick or in a new area for i, player in ipairs(game.Players:GetChildren()) do player.Character.Torso.CFrame = target + Vector3.new(0, i * 5, 0) --add an offset of 5 for each character end
While the server is waiting for the # of players to be >= 2, a message is supposed to be displayed across the screen. The message won't appear, and I'm not sure what to do. Any help is appreciated.
I would suggest using a loop to check instead of a one-time if statement.
while wait(1) do if #game.Players:GetChildren() < 2 then if not game.Workspace:FindFirstChild("PMessage") then local m = Instance.new("Message",game.Workspace) m.Name = "PMessage" m.Text = "There must be 2 or more players in the server." end elseif #game.Players:GetChildren() >= 2 then if game.Workspace:FindFirstChild("PMessage") then game.Workspace.PMessage:Remove() -- Rest of code to start the game here end end