Hello, I recently made a script for a game i’m working on.
ServerScript (ServerScriptService)
game.ReplicatedStorage.ColorChanger.OnServerInvoke = function(plr, color)
print(color)
end
Local Script (StarterGui)
local remote = game.ReplicatedStorage:WaitForChild("ColorChanger")
script.Parent.MouseButton1Click:Connect(function()
remote:InvokeServer(script.Parent.Parent.ColorPickerFrame.ColorShower.BackgroundColor3)
script.Parent.Text = "Colour changed."
wait(1)
script.Parent.Text = "CHANGE LIGHT COLOUR"
end)
Alright, so, for example if I select the color red, the output would be 1, 0, 0.0156863
What is this, what are those numbers? I googled it and it did not help at all.
Heads up: The color that is being printed is a .BackgroundColor3
property - which tends to be in RGB, not whatever those numbers was.
TestyLike3
(TestyLike3)
November 21, 2020, 9:32am
#2
You change the value using Color3, but the value itself does not include a “3”.
1 Like
It basically prints the color in Color3.new() which is basically redValue/255, greenValue/255, blueValue/255
, if you want a Color3.fromRGB value, just multiply by 255, the printed value is just your color / 255
2 Likes
TestyLike3
(TestyLike3)
November 21, 2020, 9:33am
#4
And those numbers are the integer values for the colour, so use Color3.fromRGB
if you want a colour in RGB format.
2 Likes
If you are editing a part you can use part.BrickColor = BrickColor.Red
That is an example for red sorry for the lack of detail I am on my phone.
1 Like
How would I multiply it by 255? I just tried
local col = color * 255
print(col)
and I got an error.
You would need to pull out the int values of the ego code then multiply them and add them back in.
sjr04
(uep)
November 21, 2020, 9:37am
#8
Unfortunately Color3 doesn’t have __mul
metamethod so c3 * num
isn’t possible. Just do
local col = Color3.fromRGB(color.R*255, color.G*255, color.B*255)
1 Like
Also the values cannot go higher then 255.
1 Like
TestyLike3
(TestyLike3)
November 21, 2020, 9:37am
#10
It doesn’t work that way. You are trying to multiply an instance. I think multiplying each value would work.
local col = color.R * 255
is how it works I believe. I don’t do this type of stuff much. Just use Color3.fromRGB
. It’s much simpler.
(Idk why I sound strict, I don’t mean to be rude, sorry)
1 Like
you have to multiply every value by 255, like
local r = col.R * 255
local b, g = col.B * 255, col.G * 255
print("R: "..tostring(r).."\nB: "..tostring(b).."\nG: "..tostring(g))
3 Likes
I would just do
local r = 5*5
And do the same for g and b.
1 Like