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

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

 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

✓ Accepted answer

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

2 comments

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)")

0

Nevermind. I figured out the function was running before my floorplates were created. I used WaitForChild and fixed the issue. Thank you again!

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