Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

NumPlayer script not working?

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

✓ Accepted answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.