I have this script in ServerScriptService and I’m trying to change the colors of multiple parts in a model. Here it is
–Available colors
local red = Color3.fromRGB(170,0,0)
local olive = Color3.fromRGB(151,15,156)
–Objects to paint
local part1 = workspace.Paint
local bridge = workspace.Model:GetChildren(1,2,3,4,5,6,7,8)
–Paints objects
local function painter(objectToPaint,paintColor)
objectToPaint.Color = paintColor
end
Yes, learn about tables (also known as arrays). You can make a folder in workspace, parent your parts to that folder. and then loop through them. Tables are basically variables but store multiple values. Here’s some example code:
local array = workspace.Folder:GetChildren() -- Ensure you created a folder in workspace with all these parts parented to it
for Every, Part in array do -- We are now looping through the table's elements
Part.Color = red
end
To learn more about arrays, the documentation has a tutorial about it.
You can also filter the parts and decide which one you want to color red or not. By assigning them some different properties such as names and checking in the for loop.
for Every, Part in array do
if part.Name == "ColorMe" then
part.Color = red
end
end
Edit: I see you do know about arrays, well learn about how to use for loops then. Especially with tables.