Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i make a "Waiting for Players" Lobby? [Solved]

Asked by 2 years ago
Edited 2 years ago

I Tried to do that, but i coudn't and idk what to do

Script:

local maps = game:GetService("ServerStorage").Maps:GetChildren()
local Title = game.StarterGui.MapSelector.Title
local spawns = game.Workspace.Spawns:GetChildren()
local status = game.ReplicatedStorage.Status
local LobbyCP = workspace.SpawnLocation

ti = 0

local playercount = 0
game.Players.PlayerAdded:Connect(function(plr)
    playercount += 1
end)

game.Players.PlayerRemoving:Connect(function(plr)
    playercount -= 1
end)

if playercount <= 2 then
    status.Value = "Waiting for More Players"
elseif playercount >= 2 or playercount == 2 then
    while true do
        ti = 30
        repeat
            ti = ti -1
            status.Value = "Intermission "..ti
            wait(1)
        until ti == 0

        local randomMap = maps[math.random(1, #maps)]
        randomMap:Clone().Parent = workspace
        current = randomMap.Name

        status.Value = "Chosen game is "..randomMap.Name
        wait(5)
        status.Value = "Loading game!"
        wait(2)
        status.Value = "Starting game!"
        LobbyCP.Parent = game.ServerStorage
        wait(2)

        local plrs = game.Players:GetChildren()

        for i = 1, #plrs do
            local randomSpawn = spawns[math.random(1, #spawns)]
            plrs[i].Character.HumanoidRootPart.CFrame = CFrame.new(randomSpawn.Position)
        end

        ti = 180
        repeat
            ti = ti -1
            status.Value = ti.." seconds left!"
            wait(1)
        until ti == 0

        workspace[current]:Destroy()
        wait(1)
        LobbyCP.Parent = workspace
    end
end

0
what is the problem with the script? R_LabradorRetriever 198 — 2y
0
Idk, the script is in the serverscriptservice and isn't a local script Pedrougubtz 90 — 2y
0
is there an error? R_LabradorRetriever 198 — 2y
0
no Pedrougubtz 90 — 2y
0
I think you should place the if statements inside the loop xXLegendGamerz16Xx 231 — 2y

Answer this question