for loop in roblox code example

Example 1: repeating loop roblox

while true do
	-- Your script here
    -- Every loop needs a wait increment, or your game might crash
    wait(1) 
end

Example 2: how to do for loops roblox

--roblox forloop
for count = 1, 5 do
	print(count)
end

Example 3: roblox repeat until

repeat
	spawnGoblin()
	currentGoblinCount = currentGoblinCount + 1
	print("Current goblin count: " .. currentGoblinCount)
until currentGoblinCount == 25

Example 4: how to loop something in roblox

while true do	print("Looping...")	wait(0.5)end

Tags:

Lua Example