i know that the "v" stands for the current object being targeted by the script at the time and the pairs() stands for the list of objects you want to sort through, but what purpose does "i" serve? what can it be used for?
for i, v in pairs(game.workspace.model:GetChildren()) do if v.Name == "Part" then v.Name = "ScriptAccessed" wait(1) end end
So basically, the "i" is just a variable and because you are iterating through a table, you are basically getting the "key" and "value" of each item if that makes sense.
You could put anything there! (for k, v in pairs etc.)
An example, would be:
for key, value in pairs(game.Players:GetPlayers()) do print(key) print(value) end
OUTPUT: 1 and Player1
1 is the key, because it is the 1st item in the table and Player1 is the value or object it is referencing!
Hope that makes sense!
If it did, please "Accept answer" - if not, comment below and I'll try and help more!
Marked as Duplicate by User#5423 and shayner32
This question has been asked before, and already has an answer. If those answers do not fully address your question, then please ask a new question here.
Why was this question closed?