I am still learning Lua, and I had a question when making the following: I have 3 parts in a baseplate, and I want to change their material to concrete all at once through a script in ServerScriptService. The parts are named "Colors". With the script I created below, am I able to change the "FindFirstChild" to something else in order to define all the parts under workspace?
local colors = game.Workspace:FindFirstChild("Colors")
colors.Material = Enum.Material.Concrete
You could use a for i, v loop to loop through all the children of the baseplate, but this is advanced.
I don’t remember how to do this right now, but there are some tutorials on YouTube about for loops in Lua on Roblox.
I would just make each part have a different name and make a separate variable for each part: ( If you are a programmer and see this, sorry for possibly burning your eyes. )
local partA = game.Workspace:FindFirstChild("partA")
local partB = game.Workspace:FindFirstChild("partB")
local partC = game.Workspace:FindFirstChild("partC")
partA.Material = Enum.Material.Concrete
partB.Material = Enum.Material.Concrete
partC.Material = Enum.Material.Concrete
Yes, I also knew this was a solution to my problem, however, I do plan on adding way more than 3 parts to the game so I need a more ‘simple’ script. I will try and do some more research for a loop (which I’m slightly familiar with).