✓ Accepted answer
a = game.Workspace:GetChildren()
for i = 1, #a do
if (a[i].className == "Part") then
a[i].Reflectance = 1
else return end
end
All ROBLOX instances within the service (workspace) are returned in a list, which is assigned to a. a then becomes a table containing the list.
the length operator (#) on the second line followed by a table returns an integer that represents just the index of the last value of the table. In other words, the total number of values in said table.
a[i] just simply means accessing the value located at index i of table a. Since all values have a unique corresponding index, and that indices are integers, we can only get the value using the index -- because we want the value, and not the number.
For a much easier understanding of how it all works, here's a little cleaner version of the snippet you've provided.
list = workspace:GetChildren()
for index = 1, #list do
if list[index].className == "Part" then
list[index].Reflectance = 1
else
return
end
end
6 comments
FAK! I HAD A WHOLE ANSWER AND I REFRESHED! I HAD MORE EXPLAINATION THAN YOU!!! Dang it.
Ty for the help
If you understand and have no further questions, accept answer please :D
good answer image. +1 for you. give me cookies now
How I accept answer I don't know sorry I'm new to this(noob)
It may be better to use a 'Generic For' loop for these types of situations. :P