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

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

Asked by
RoJiyn 12
7 years ago
Edited 7 years ago

Please provide more explanation in your question. If you explain exactly what you are trying to accomplish, it will be much easier to answer your question correctly.

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

Log in to vote
0
Answered by 7 years ago

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.

Ad
Log in to vote
0
Answered by 7 years ago

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

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. User#5423 17 — 7y
1
Yes you can. BrickColor.new(Color3.fromRGB(255,0,0)) --BrickColor will round the values to the nearest BrickColor of that variant. M39a9am3R 3210 — 7y
0
Thanks RoJiyn 12 — 7y

Answer this question