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

"new is not a valid member of BrickColor" Script Error?

Asked by 3 years ago
 local ColorFloor = game.Workspace.ColorFloor
 local ColorFloorChildren = ColorFloor:GetChildren()

 local function ColorChange()
    for i = 1, #ColorFloorChildren do
        local randomnumber = math.random(0, 10)

        if randomnumber == 1 then
            ColorFloorChildren[i].BrickColor.new(128, 187, 219)
        end
    end
end

ColorChange()
I want to have a code where it will run a script that randomly chooses a number. Which will determine which color to apply to the Part (Labelled as "ColorPlate"). My problem is for some reason (Probably a typo but I am blind), I'm getting the error "new is not a valid member of BrickColor" from doing this. Any suggestions?

1 answer

Log in to vote
0
Answered by 3 years ago

Hello,

It appears that you are checking the property "BrickColor" instead of assigning a new color value.

To fix this, simply change the code from:

ColorFloorChildren[i].BrickColor.new(128, 187, 219)

To:

ColorFloorChildren[i].Color = Color3.FromRGB(128,187,219)

Hopefully, this helps!

Cheers, Ninjamanchase

0
Thank you so much, I believe that's fixed! Unfortunately I was given another error hopefully unrelating to the previous. It stated ("ServerScriptService.Script:9: attempt to call a nil value - Server - Script:9 issue"). The line it focuses is ("ColorFloorChildren[i].Color = Color3.FromRGB(128,187,219)") CrazySOB7 7 — 3y
0
Nevermind. I figured out the function was running before my floorplates were created. I used WaitForChild and fixed the issue. Thank you again! CrazySOB7 7 — 3y
Ad

Answer this question