Script to change colour and material of multiple parts, need help!

I’m very very new to scripting as you can tell from the following lua block. What I need to know is if i can, and how, to select multiple parts to change in one script. I know I could tediously script in every single part, but that wouldn’t be practical. What I tried to do here is select a folder in workspace with multiple parts, all exactly the same and under the same name. I would know how to do this if I had to script each individual block, but is there a faster way?

local lights = game.Workspace.LightSet.Children

while true do 
    lights.BrickColor ="Lilac")
	lights.Material = Enum.Material.Neon
1 Like

Its possible. I would reccomend you to put all the parts you want to change in a folder. After that you do:

local folder = game.Workspace.Folder

local parts = folder:GetChildren()

for i, v in pairs(parts) do
v.BrickColor ="Lilac")

I did this fast I probably spelt something wrong. But this should work


i had this question too. this might work for you:

You could do a for loop for example:

for i, parts in pairs(workspace.Parts:GetChildren()) do
 parts.BrickColor = BrickColor.New(“Lilac”)

I use for loops for pretty much everything since they are pretty handy :slight_smile:

1 Like

Also the while loop was an accident not sure how I got that in there

1 Like

You’re Welcome!! Glad I could help. I recommend watching TheDevKing’s Advanced tutorial series but make sure you know the basics before diving in!! I learned all that from there. wish you the best of luck on your game!!

I agree with what you said, but the best way to learn(Not meant for everyone) is to look at the docs, since it has everything you need that isnt bug related.
They have really good examples and how to use things.

Have a good day/night cya! :slight_smile:

1 Like