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

How do I check if a GUI has a certain background colour?

Asked by 4 years ago

I want to check whether a GUI I have has a certain background colour, but I tried to use color3 but it doesn't seem to work. If anyone could tell me something that I am doing wrong, that would be great. Here is my code:

for i,v in pairs(foodCatagories) do
    v.MouseButton1Click:Connect(function()
        if v.BackgroundColor3 == Color3(0,255,255) then 
            print("Hello")
        end
    end)
end



2 answers

Log in to vote
2
Answered by 4 years ago

What IceAndNull said is correct, but for GUI elements you wan't to use Color3.FromRGB() so

if v.BackgroundColor3 == Color3.fromRGB(0,255,255) then

Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Instead of using Color3(0,255,255) it’s Color3.new(0,255,255)

Edit: as kaspar1230 pointed out, use Color3.fromRGB(0,255,255) instead of Color3.new()

Answer this question