Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

BrickColor is not a valid member of Script for Dance Floor?

Asked by 4 years ago

For a self mini-project on while loops and in loops, I decided to script a dance floor today. The problem I noticed right away was the colors, which are randomly assigned from a local list of picked colors, changed once and is like that for the rest of the testing. What I'm trying to do is have the colors change every 0.75 seconds.

I noticed in the output browser it says BrickColor is not a valid member of the script which I quite don't understand since I'm a beginner. Would love to know those type of errors exactly mean. Thanks.

Here is the code:

local colors = {"Bright red","Bright blue","Bright green"}
local max = table.getn(colors)

while wait(0.75) do
    for _, v in pairs(game.Workspace.DanceFloor.Lights:GetChildren()) do
        v.BrickColor = BrickColor.new(colors[math.random(1,max)])
    end
end

3 answers

Log in to vote
0
Answered by 4 years ago

Use Instance:IsA() to check if v is a basepart(Part, union, or meshpart) and if so, change it's brickcolor. Your code was erroring because there is an object in Lights that wasn't a part, meaning you can't change its brickcolor.

local colors = {"Bright red","Bright blue","Bright green"}
local max = table.getn(colors)

while wait(0.75) do
    for _, v in pairs(game.Workspace.DanceFloor.Lights:GetChildren()) do
    if v:IsA("BasePart") then --check if v is a basepart
             v.BrickColor = BrickColor.new(colors[math.random(1,max)])
    end
    end
end
0
That was interesting since in the lights model, there were only parts, but this solution worked flawlessly Dostoevski 2 — 4y
Ad
Log in to vote
0
Answered by
Ghost40Z 118
4 years ago

Try doing this.

while true do
    wait(0.75)
    for _, v in pairs(game.Workspace.DanceFloor.Lights:GetChildren()) do
        v.BrickColor = BrickColor.new(colors[math.random(1,max)])
    end
end
0
It should loop it forever Ghost40Z 118 — 4y
0
I tried it, but it still gives me the same error with "BrickColor is not a valid member of Script" in output Dostoevski 2 — 4y
0
Check the other person sent a script, try theirs. Ghost40Z 118 — 4y
Log in to vote
-1
Answered by 4 years ago
while true do
script.Parent.Color = Color3.new(math.random(), math.random(), math.random())
wait(0.5)
end

This is a really old script, but it works like a charm. Make sure that its a server script and is in every part you want to change color in.

0
Yeah that's another way you can do it, put a script in every block Ghost40Z 118 — 4y
0
This worked fine, but the goal I had in mind for this mini-project was to use a list of picked colors and have that randomly assigned to each brick in a in pair loop Dostoevski 2 — 4y
0
you can change the "math.random()" to your color EmptyVib_es 3 — 4y

Answer this question