StefanAlmighty Posted October 26, 2015 Share Posted October 26, 2015 Quick question for a future project I am working on: how can I create a loop which only loops 10 times? For example: local example = 0 for index, val in ipairs do example + 1 end So in theory, example would end at 10. How would I do this? Link to comment
AMARANT Posted October 26, 2015 Share Posted October 26, 2015 for i=1,10 do outputChatBox(tostring(i)) end Link to comment
sanyisasha Posted October 26, 2015 Share Posted October 26, 2015 Loops: for i=1,10 do --todo end for i=10,1,-1 do --todo end for i,v in pairs(a) do --todo end Link to comment
Noki Posted October 27, 2015 Share Posted October 27, 2015 You can also use local i = 1 while i <= 10 do i = i + 1 end But the above "for i=1,10 do" method is better. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now