Understanding the Dos and Don'ts

Hey Scripters,

I’m learning Lua and want to understand the do’s and don’ts of using for and while loops. What are some best practices or common mistakes to watch out for? Any quick tips or examples would be great!

First dont for while loops is that you should not use them mainly in client sided scripts instead use runservice. You can learn more about it in the docs btw. The do for it is to use it for server sided loops only, while for loops are used to iterate over an array like:

local a = {"Hi","Friend","!"}
for Index,String in pairs(a) do
    print(Index..String)
end

Or to count.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.