✓ Accepted answer
Your code was just about right except two parts of it. When you use this method your going through a table of objects. So P is considered a table, and "i" is the loop (count). In tables there are numbered objects.
Example: P[1]
So when using this method you want to do P[i]. Also you want to do "for i = 1,#P". # means "Number" basically.
http://wiki.roblox.com/index.php?title=Table
local Color = script.Parent.TeamColor
local P = script.Parent.Team:GetChildren()
for i = 1,#P do
P[i].BrickColor = BrickColor.new(Color.Value)
wait()
end
UndiscoveredLimited's answer was more sufficient, I thought it was gone, but I guess it's not so I will just keep what I just edited. If you don't understand what for _ ,v in pairs(EXAMPLE:GetChildren()) do means then I suggest you take a look at the link below. Its the best that I could find in a flash.
local Color = script.Parent.TeamColor
for _,v in pairs(script.Parent.Team:GetChildren()) do
v.BrickColor = BrickColor.new(Color.Value)
wait()
end
http://wiki.roblox.com/index.php?title=Function_dump/Basic_functions#pairs
I hope you understand it better now.
1 comment
Where is this script inside of?