Hello, I’m trying to compare the color of a button to see if its a specific color. For example here is my script:
for i,v in pairs(game:GetDescendants()) do
if v:IsA("TextButton") and v.BackgroundColor3 == Color3.new(0.631373, 0.258824, 0.258824) then
-- do stuff here
end
end
for i,v in pairs(game:GetDescendants()) do
if v:IsA("TextButton") and v.BackgroundColor3 == Color3.fromRGB(0.631373, 0.258824, 0.258824) then
-- do stuff here
print("Yo")
end
end
Now I feel that using directly color3.new instead of rgb is a bit unreliable since it can cause precision problems such as float points of comparing if its 0.4 but in reality color3 is 0.4546547457, you get the point, use what @RafehPvP said use from RGB.
Wait I just noticed why are you going through all descendants of the game… Put all your Gui in StarterGui and whenever you need to do something, do it in a local script inside Player.PlayerGui.