lua loop code example

Example 1: lua for loop

-- For K,V in table
for k,v in pairs(tbl) do
 print(k)
 print(v)
end
-- For i=0, num
for i=0, num do
 print(i)  
end

Example 2: lua while loops

--// Basic while true do loop

while true do
	
	--// Looped text
	print("Looped Text")
	
	--// Time the loop waits before looping again
	wait(1)
end

Example 3: lua how to make a loop

for init,max/min value, increment
do
   statement(s)
end

Example 4: For loop lua

for startValue, EndValue, [increments] do
        --code to execute
end
--The increments value is optional.  If it isn't defined, it is assumed to be "1"

Example 5: for loop lua

local t = {}
for index, value in ipairs(t) do
	print(index, value)
end

Example 6: for loop lua

for x = 0, 10, 1 do
	print(x)
end

Tags:

Lua Example