Edit: Closed because for some reason it started working after making no changes whatsoever. Bizarre, but glad it is working now?
Hello!
In my game I need to set the color of multiple parts based on a random BrickColorValue which is sharing the same parent as the localscript. It is a simple script, and should be working, but there are no errors and nothing happens.
The code:
local val = script.Parent.treeType
val.Value = math.random(1,5)
local val2 = script.Parent.leafColor
val2.Value = BrickColor.Random()
local val3 = script.Parent.trunkColor
val3.Value = BrickColor.Random()
local children = workspace.Model.Tree1:GetChildren()
for i, child in ipairs(children) do
if child.Name == "Leaves" then
child.BrickColor = val2.Value
end
if child.Name == "Trunk" then
child.BrickColor = val3.Value
end
end
I apologize if the error is simple and I just missed it. This is honestly quite weird for me.
Thanks!

1 comment
Take it off the workspace and redeclare the variables.