Statements don’t work with loops?

Hello!
I was wondering because I have a statement in a while loop and it will only run one time. Do statements not work in a loops? Please tell me another way if possible. Thanks!

They should work just fine. Can we see the code please?

I’m totally sure that If statements works perfect inside loops, maybe ur statement is not found

while true do
wait()
for i, team in ipairs(teams) do
local count = #team:GetPlayers()
if count < minvalue then
minvalue = count
minindex = i
print(minvalue)
end
end

if minindex ~= -1 then
	print("teams with least players is " ..teams[minindex].Name)
else
	print("Error line 16.minindex ~= -1 attempt to call a nil value")
end

end

local teams = {game.Teams["Purple Kingdom"], game.Teams["Blue Kingdom"], game.Teams["Red Kingdom"], game.Teams["Green Kingdom"]} -- put all teams into that table
local minvalue = math.huge
local minindex = -1

while true do
	wait()
	for i, team in ipairs(teams) do
		local count = #team:GetPlayers()
		if count < minvalue then
			minvalue = count
			minindex = i
			
			if minvalue == #teams[1]:GetPlayers() then -- Purple Kingdom with least
				print("a")
			end
			
			if minvalue == #teams[2]:GetPlayers() then -- Blue Kingdom with least
				print("b")
			end
			
			if minvalue == #teams[3]:GetPlayers() then -- Red Kingdom with least
				print("c")
			end
			
			if minvalue == #teams[4]:GetPlayers() then -- Green kingdom with least
				print("d")
			end
		end
	end
	-- end of loop 1
end

will not work.

i8m dumb I have it in an if statement :grinning: