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

For loop help?

I was wondering why putting a for loop inside another loop doesn't work as expedited?

Example of what I mean

Output

a : 10 b : 5 c : 2

a : 7 b : 5 c : 2`

a : 4 b : 5 c : 2

a : 1 b : 5 c : 2

Script:

for a = 10,1,-3 do
		b = 5,1,-2 -- a =
			c = 2,1,-1
	print("a : "..a.." b : "..b.." c : "..c)
end

Why does this happen?

1 answer

You didn't actually put another loop inside at all. You merely initiated variables and declared them

Here is a fix:

for a = 10,1,-3 do
     for b = 5,1,-2
          for c = 2,1,-1
             print("a : "..a.." b : "..b.." c : "..c)
         end
   end
end

1 comment

0

Lol my bad

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