I am new to scripting, can someone help me here?
You use pairs for iterating over an array or a dictionary For example
local t = {1, 2, 3, 4, test = 5} for i, v in pairs(t) print(i, v) end
This will print all values in the table along with their indexes You can also use next for doing the exact same thing
local t = {1, 2, 3, 4, test = 5} for i, v in next, t do print(v) end
Lets say you want to change the color of all parts in a model You can use the GetDescendants method to get everything in the model and then check if the thing is a part, if it is a part, set its color to whatever you desire
for i, part in pairs(model:GetDescendants()) do -- check if the descendant is a part if part:IsA("BasePart") then -- change its color to white part.Color = Color3.fromRGB(255, 255, 255) end end
It is possible to substitute pairs with next