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

[Closed]Why " 18:50:34.036 - Color cannot be assigned to"?

Here is the scripts

----Variables--------------------------
local p = script.Parent
print("Test")
print("Test.")
------------------functions--------------------------------------
function OnTouched(fall)	
local h = fall.Parent:FindFirstChild("Humanoid")---Need to rmb is hit
	if h ~= nil then
		p.BrickColor.Color = BrickColor.new(128,255,0)-- Color Codes from: http://www.rapidtables.com/web/color/RGB_Color.htm
		p.CanCollide = true
		wait(3)
		p.BrickColor.Color = BrickColor.new(225,0,0)
		p.CanCollide = false
		wait(3)
		p.BrickColor.Color = BrickColor.new(128,255,0)-- Color Codes from: http://www.rapidtables.com/web/color/RGB_Color.htm
		p.CanCollide = true
	end
end
script.Parent.Touched:connect(OnTouched)

Thanks!

2 answers

✓ Accepted answer

There are two problems here, the 1st is that the BrickColor.Color is read only so you cannot set its value, you need to pass a new brick color each time.

The second is that you need to / 255 as it uses the range 0 ~ 1, more information can be found in the BrickColor Constructors.

I prefer to use:-

p.BrickColor = BrickColor.new(Color3.fromRGB(225,0,0))

But you can also use:-

p.BrickColor = BrickColor.new(225/255,0/255,0/255))

I hope this helps.

You CANNOT assign a brickcolor from RGB (red, green, blue). So you go to brickcolor in properties and hover over a color u want the color to be. REMEMBER IT IS CASE SENSETIVE. Like this

script.Parent.BrickColor = BrickColor.new("Bright green") --i dont remember where to capitalize, so this might be wrong

Gui's have colors from RGB, though. But this is a brick. Not a gui

3 comments

0

You can use a Color3 to create a BrickColor and you can create one with r,g,b but you must /255 as it has a range from 0 - 1.

1

Yes you can. BrickColor.new(Color3.fromRGB(255,0,0)) --BrickColor will round the values to the nearest BrickColor of that variant.

0

Thanks

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