I can't assign BackgroundColor3 to Color3.new()

I want to change gui object background color ,but it gives me an error in return and I don’t understand why.
Here’s an example how it looks like.

local black = Color3.new(0,0,0)
local GUIobject = script.Parent
GUIobject.BackgroundColor3 = black
--output BackgroundColor3 cannot be assigned to 

Could you take a screenshot of the entire error? I think that’ll make it easier to figure out what the problem is.

Can’t you just use Color3.fromRGB?

What is the GUI object you trying to set the color of?

I wonder why’d you do it in the deferred way. You should instead use:

local GUIobject = script.Parent
GUIobject.BackgroundColor3 = Color3.new(0,0,0)

No beacuse i made palette of colors and they must fit into if statements and make mess on the way

if new didn’t work then RGB won’t work either
EDIT: rgb looked weird because of autocorrect

What did it print? Click on the drop down menu.

maybe this is nil???
but it would say it can’t assign to nil not “”
never got that error where it says nothing at all

how black variable could be nil?

Ok then the problem is probably that the object you are trying to set the BackgroundColor3 to is not a frame.

So before you set the background color you should check if it is a frame like so:

if v:IsA("Frame") then ...

Try printing all of the table’s value’s children’s BackgroundColor3’s to see which one is causing the problem.

like I said I never got it to say nothing at the end so I’m guessing

it is beacuse i cloned this object form replicated storage and it’s class name is a frame

1 Like

black variable isn’t nil

when I say nothing I’m not talking about nil
idc if they mean the same thing

do you want me to continue saying “”
that’s kinda annoying

I’m trying to solve the problem and that’s why I am here.

Why are you using GetGuiObjectsAtPosition anyways? That could be the problem.

How this could be a problem?
It just gets instances and returns a table.