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

How do i stop this bit of code from running?

if there is less than 2 players how would i stop the script from running until there is enough.

game.Players.PlayerAdded:connect(function()
	if game.Players.NumPlayers < 2 then 
		mm = Instance.new("Message",Workspace)
		mm.Text = "Not enough players"
		wait(1)
		mm:Remove()
	else
		if game.Players.NumPlayers >= 2 then
		mmm = Instance.new("Message",Workspace)
		mmm.Text = "enough players"
		wait(1)
		mmm:Remove()
		script:Remove()
		end
	end -- around here
	m = Instance.new("Message",Workspace)
	m.Text = "You are Chosen"
	wait(5)
	m:Remove()
	players = game.Players:GetPlayers()
	killer = players[math.random(1,#players)]
	print("You are chosen")
end)

1 answer

Use repeat. The following code waits until the given amount of players are there.

repeat wait() until game.Players.NumPlayers > 2

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