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

How can I compare to Color3 values?

Example:

if Color3.new(255/255,255/255,255/255) >= Color3.new(255/244,255/244,255/244) then
	print("Woah!")
end

I get an error saying:

attempt to compare two userdata values

3 comments

0

In what way do you want to compare them?

0

Do you want to know which one is "brighter"? If so, what kind of "brightness" do you need? Is light gray brighter than pure red? etc?

0

Also: you can use Color3.fromRGB(255, 255, 255) instead of manually dividing by 255 with Color3.new

1 answer

✓ Accepted answer

Convert them to vectors then compare their magnitude.

local c1, c2 = Color3.new(1,1,1), Color3.fromRGB(244,244,244)

if Vector3.new(c1.r,c1.g,c1.b).magnitude >= Vector3.new(c2.r,c2.g,c2.b).magnitude then
    print("Woah!")
end

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