Why wont script detect variable as true

script wont detect that the variable “enoughplayers” was made true i have no idea why



local PlrNeeded = 2
local CountdownStart = 5
local current amount = 0
local enoughplayers = false
local random = false

repeat
wait(1)
local plramount = game.Players:GetChildren()
if #plramount >= PlrNeeded then
		
		enoughplayers = true
		print(enoughplayers, "is true")
	else
		enoughplayers = false
end
until random == true 

repeat
	wait(1)
	if enoughplayers == true then ---This line here is broken
		print("Detected true")
		wait(3)
		for i,v in ipairs(game.Players:GetChildren())  do
			print("part2")
			print(v.Name)
			
		end
	end
until random == true

Well, you stated that the number of players needed is two, so if you’re testing it solo, that if statement won’t be met due to there being only one player (you).

im testing using server
image

Is there any message that gets printed?

this line gets printed

	print(enoughplayers, "is true")

Does “enoughplayers” print as true?

yes Filler for character minimum

repeat
wait(1)
local plramount = game.Players:GetChildren()
if #plramount >= PlrNeeded then
		
		enoughplayers = true
		print(enoughplayers, "is true")
	else
		enoughplayers = false
end
until random == true --This should be changed to enoughplayers == true
                                            idk what the random variable is but you need to ask if enoughplayers equals true

Also, your second repeat loop won’t run until the first repeat loop is done.

1 Like

the random variable is just a random variable made to keep it repeating

That’s why the second repeat function won’t work because random is still equal to false.

1 Like

On another note, not that it’s terribly important, but any use of “== true” is redundant, because all it’s going to do is check if a value is true, and yield the result of true if they’re the same

-- Assume
SomeVariable = true

-- An example of using SomeVariable in an if-statment
if SomeVariable == true then

-- This can be simplified as
if true == true then

-- Now we do the comparison
if true then

-- We could just skip the redundant step of comparing the 2 values entirely by not doing it at all
if SomeValue then
if true then
repeat
	Players.PlayerAdded:Wait()
until #Players:GetPlayers() > 1