Ciao, i have a script that checks which color your avatar has and depending on that it chooses a prashe.
Even tho the colors are right, it doesn’t seem to find it’s match
--Corpo
local Torso = Giocatore.BodyColors.TorsoColor3
local Gambe = Giocatore.BodyColors.RightLegColor3
print(Torso,Gambe) --output(1, 0.564706, 0.85098 1, 0.564706, 0.85098)
if Torso == Gambe then
print("IN") --gets printed
if Torso == Color3.new(0.109804, 0.419608, 0.780392) then
print("1")
return "Ah, you didn't change?"
elseif Torso == Color3.new(0.631373, 1, 0.431373) then
print("2")
return "Matching the grass?"
elseif Torso == Color3.new(1, 0.564706, 0.85098) then
print("3")
return "You look like a Barbie"
elseif Torso == Color3.new(1, 0.392157, 0.392157) then
print("4")
return "Good choice"
end
end
The script can’t seem to find it’s match, which is the number 3 in this case.
I tried searching around but found nothing, sorry for disturbing
1 Like
Might be happening due to floating-point error, making the colors close but not exact matches
Try using Color.fromRGB
instead of Color.new
, but you’ll need to input the color values using the 0-255
number range instead of 0-1
1 Like
That is because TorsoColor3
is an RBG color.
To fix, this replace
with
if Torso == Color3.fromRGB(255,255,255) then -- Change 255,255,255 with your color
1 Like
Didn’t work neither with the RGB colors, but i have found a solution for this. I would like to thank you both anyway, i appreciate the help.
I have added this function to the script
local function areColorsEqual(colorA, colorB, epsilon)
local epsilon = epsilon or 0.001
if math.abs(colorA.R - colorB.R) > epsilon then
return false
end
if math.abs(colorA.G - colorB.G) > epsilon then
return false
end
if math.abs(colorA.B - colorB.B) > epsilon then
return false
end
return true
end
I found it here: How can I compare two Color3 inputs? - #2 by Maximum_ADHD
system
(system)
Closed
July 1, 2024, 3:30pm
#5
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.