Could you please explain the difference between a numeric and a generic for loop?
Basically, a numeric for loop loops over a certain array of numbers with a certain increment. For example,
for x = 1,5,2 do print(x) end will print 1, 3 and 5.
A generic for loop is another type of for loop. You basically use the for loop as iterator again, but now you will use a function to get the values. One of the most used functions for a generic for loop is pairs(). This will slide a table index and it's value to the values;
local tab = game.Workspace:GetChildren() for index, instance in pairs(tab) do print("Instance number: "..index.." of game.Workspace has name: ".. instance.Name) end
This will print all names of all children of workspace.
Locked by FunctionalMetatable and Leamir
This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.
Why was this question closed?