Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

So simple yet so confused?. BrickColor is not a valid member of Script.

When I run the script the parts do change, but once the script changes all parts the script breaks and throws this error BrickColor is not a valid member of Script, any reason as to why this happens?

local danceFloor = script.Parent:GetChildren()

while true do
	for i,v in pairs(danceFloor) do
		v.BrickColor = BrickColor.Random() -- script breaks here 
		wait()
	end
end

1 answer

✓ Accepted answer

You need to check if the Children you're getting with :GetChildren() is a basepart(a Part, Meshpart or union)

local danceFloor = script.Parent:GetChildren()

while true do
    for i,v in pairs(danceFloor) do
        if v:IsA("BasePart") then -- check if its a part,meshpart or union
            v.BrickColor = BrickColor.Random() -- script breaks here 
        end
        wait()
    end
end

1 comment

0

Ah thank you so much I was so confused.

This discussion is preserved as it was. New answers, comments, and votes are closed.