Instead of typing out
var1 = part1
var2 = part2
Etc...
Is there a way to combine then into one variable?
Instead of typing out
var1 = part1
var2 = part2
Etc...
Is there a way to combine then into one variable?
The best way to go about doing what you're trying to do is to store the variables and/or references in an array. This way, you can easily change the properties of the parts just by a simple iteration of the array.
I will give an example. Assume the following situation; We have two parts in workspace named "Part1" and "Part2" respectively.
We can do the following:
local parts = {workspace.Part1,workspace.Part2}
for _,v in pairs(parts) do
v.BrickColor = BrickColor.new("Institutional white")
v.Name = "This brick has been changed!"
end
The following code would change the properties of any and all bricks stored within the parts array, and change their properties based on the given code.
For Loop: http://wiki.roblox.com/index.php?title=In-Depth_Scripting_Guide#The_.27for.27_Statement
Tables/Arrays: http://wiki.roblox.com/index.php?title=Table
This discussion is preserved as it was. New answers, comments, and votes are closed.