There is no errors shown by output or developer console.
while true do wait()
parts = script.Parent.Parent:GetChildren() for x = 1, #parts do if parts[x].Name == "PartC" then parts[x].BrickColor = script.Parent.Value end end end
What am I doing wrong?
A few tips:
1.) while wait() do
is the same as while true do wait()
. You could also use the heartbeat event from the runservice.
--All of these are practically the same. while wait() do end --These 2 are the same while true do wait() end ------------------------------------------------------------------------------- game:GetService("RunService").Heartbeat:connect(function()--This is slower by 0.004 seconds. end
2.) You can use pairs instead of for i = 1,#
..etc.
for i = 1,#game.Players:GetChildren() end --same for _,player in pairs(game.Players:GetChildren()) do end
3.) You can use the :IsA()
to see if it's a part.
if workspace.Part:IsA("Part") then --If it's a part print("Part's class name is Part") end if workspace.Part:IsA("BasePart") then print("Part could be a wedge, corner wedge, cylinder, Sphere, Regular Part, etc.") end
With all these tips we can finally fix your problem.
Problem: You have too many ends! You only need 2 for this script. Also, check to see if script.Parent is a BrickColor Value.
parts = script.Parent.Parent:GetChildren() for _,x in pairs(parts) do if x:IsA("Part") then x.BrickColor = script.Parent.Value end end --You only need 2 ends. Not 3.