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

NumPlayer script not working?

Asked by
TrollD3 105
8 years ago

This is a local script inside the StarterGui. Idk why its not working as I have revised this code several times.

repeat wait() until game.Players.LocalPlayer.PlayerGui.Menu.Main.plr

local plrstart = 2
local roundinsession =  false
local plr = game.Players.LocalPlayer
local plrgui = plr.PlayerGui
local char = plr.Character
local curplr = game.Players.NumPlayers
local gamestart = false

repeat
    wait(1)

if curplr<plrstart then 
    plrgui.Menu.Main.plr.Visible = true
    if plrstart-curplr ==1 then
        leftplr = plrstart-curplr
    plrgui.Menu.Main.plr.Text = "You need " ..leftplr.. " more Player(s) to start"
    print"not enough plrs"


    elseif leftplr>1 then
            plrgui.Menu.Main.plr.Visible = true

            plrgui.Menu.Main.plr.Text = "Enough Players."
        plrgui.Menu.Main.plr.gamestart.Value = true
        print"enough plrs"


    elseif leftplr==0 then
            plrgui.Menu.Main.plr.Visible = true

            plrgui.Menu.Main.plr.Text = "Enough Players."
        plrgui.Menu.Main.plr.gamestart.Value = true
        print"enough plrs"


    end
end

until
plrgui.Menu.Main.plr.gamestart.Value == true

1 answer

Log in to vote
0
Answered by 8 years ago

Use this to get the amount of players.

spawn(function() 
    while true do
        for i,v in pairs(game.Players:GetPlayers()) do
            numPlrs=i
        end
        wait()
    end
end)
Ad

Answer this question