Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What does "in pairs" do?

Asked by 10 years ago

Can someone please explain what the "in pairs" in for loops does?

1 answer

Log in to vote
0
Answered by
LevelKap 114
10 years ago

i = index v = the current index value this loops through the table for its values or parents for its children. this loop basically scans through everything inside an object or whatever and returns a value. Example:

for i, v in pairs(Workspace.Model:GetChildren()) do
if  v.Name == "Wall" then
v.Transparency = 0.5
end
end

this would loop through a model in the workspace named model and look for an object with the name wall, if it find one, it would change the objects transparency to 0.5. This is usefully for changing multiple items in your place or getting special things from your player.

If you need more help, pm me at LevelKap on ROBLOX. thumbs up is appreciated, i wanna reach contributor status :DDDDDD

Ad

Answer this question