Hi
So I am trying to make a script change the color of text using Color3:fromRGB and it works fine except for the value which I have entered, this being (0, 221, 0) appears blue when it should appear green.
Every green value appears blue, and every red value appears green and if you put a blue value, it appears black for some reason.
Could someone have a look at this for me?
function ok()
script.Parent.Screen.MainScreen.SurfaceGui.Frame.Frame.Idle.TextColor3 = Color3:fromRGB(0, 221, 0)
print ("didn't detect any bad tools")
script.Parent.Lights.LeftLights.Light1.Color = Color3:fromRGB(0, 221, 0)
script.Parent.Lights.LeftLights.Light2.Color = Color3:fromRGB(0, 221, 0)
It goes on like that forever because there are a lot of lights
Make sure to use Color3.fromRGB() instead of :fromRGB()
5 Likes
Maybe it’s affected by the lighting in the game? If you got any specific lighting already in the game, then it may shift the colour to a different one.
It’s because your using :fromRGB. Use .fromRGB
I can’t really explain why this happens, its something to do with self
and im too tired to go into it right now
This happens because of the :
, use .
instead.
Reasoning
When you use :
, you are basically telling the function “Hey, use the thing I just used to invoke the function as the first variable!”. There’s a whole bunch of stuff with self
and whatnot, but for this function, it’s simpler.
By using :
, you are basically doing this:
Color3:fromRGB(0,221,0)
-- Is the same as
Color3.fromRGB(Color3,0,221,0)
This is because it thinks it needs to use Color3 as the first variable, and since there’s no 4th argument, it ignores the last one and interprets the Color3
argument as 0, since it can’t convert the Color3
table to a number… It makes sense that blue is nothing, because it interprets it as this:
Color3:fromRGB(0,221,0)
-- To
Color3.fromRGB(Color3,0,0,221)
-- To
Color3.fromRGB(0,0,0,221)
-- To
Color3.fromRGB(0,0,0)
2 Likes
What he said. He explained what i tried to explain, basically.
Didn’t think about that, just me being a bit stupid.
Thanks,