When I print B and G values they are nil

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I am trying to make it so when a player clicks a GUI button, a brick will turn that color.

  1. What is the issue? Include screenshots / videos if possible!

The issue is when I try to send R, G, and B values through a remote event the event somehow makes R all three (If I print R it will print all 3 values under R and make G and B return nil). Here’s some pics of the output and the scripts.

Local script:

local Player = game.Players.LocalPlayer

local BB = script.Parent.TextButton_Roundify_12px.ImageColor3.B
local RR = script.Parent.TextButton_Roundify_12px.ImageColor3.R
local GG = script.Parent.TextButton_Roundify_12px.ImageColor3.G

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local remoteEvent = ReplicatedStorage:WaitForChild("ChangeColor")

function leftClick()

function rightClick()



local ReplicatedStorage = game:GetService("ReplicatedStorage")

local remoteEvent = ReplicatedStorage:WaitForChild("ChangeColor")

local function onChangecolor(player,RR,GG,BB)
	print(player.Name .. " Changed the color to"  )
	game.Workspace.Part.Color = Color3.fromRGB(RR,BB,GG)
	game.Workspace.Part.Color = Color3.new(RR,BB,GG)



  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I tried changing variable names (as explains the AA, BB type of approach) thinking that was the issue. Turns out that was not the issue. As you can see I also did two methods in hopes to get a better (if not any) result from the other method. Unfortunately, none of this worked.

I notice you’re using BG instead of BB, but it doesn’t explain why RR is a Color3 on the server.

1 Like

Oops! :sweat_smile: made a typo.

From your output below, I noticed your RR variable is equal to the entire Color3 or is equal to a string which contains the three values. Are you ever reassigning anything to RR after firing the server, or is this your entire script?

1 Like

So after I read this I went and checked if this might be the issue. I do not think it’s the issue but I realised that I was clicking the wrong button from the script I was working on. The RGB prints correctly in the local script and the server script. Though when i try to change the color it becomes this color which is magenta Screen Shot 2021-01-18 at 9.24.17 PM .

The color is supposed to be yellow

To be clear: I use Color3.fromRGB and it turns black
If I use Color3.new it gives me magenta

1 Like

Thanks for that.

I noticed you are assigning the part’s colour two times. Is it coloured incorrectly both times?

Another thing, why not just use the Color3 as the argument to the server in its entirety instead of firing all three values separately and then try assigning it that way?


1 Like

Yes. Both times it is color some weird color that isn’t correct. And also I’ll try that method and see how that works

Edit: Tried it and now both methods turns to black

1 Like

Ah okay, we’re getting somewhere.

Instead of using Color3.fromRGB, try using Color3.new and check if that solves anything. When trying to read a Color3 it gives the Color3.new value instead of the RGB value.

You’re able to convert it to RGB like this:

local colour = Color3.new(1,1,1)
local colourRGB = Color3.fromRGB(colour.R * 255, color.G * 255, colour.B * 255)

Capture d’écran, le 2021-01-18 à 22.37.41
Capture d’écran, le 2021-01-18 à 22.38.24

1 Like

Thanks! I used the RGB version since I want this to be fully customizable and I understand that a little bit better. Thank you!

1 Like

No worries.

The only difference between Color3.fromRGB and Color3.new is that Color3.new’s values are just divided by 255 and Color3.fromRGB’s values are multiplied by 255. I assume it’s just for memory/storage. You could also create your own function for efficiency/readability.

local function toRGB(colour)
    return Color3.fromRGB(colour.R * 255, color.G * 255, colour.B * 255)

print(toRGB(Color3.new(1,1,1)) --> 255,255,255