You can write your topic however you want, but you need to answer these questions:
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.
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
print(script.Parent.TextButton_Roundify_12px.ImageColor3.B)
print(script.Parent.TextButton_Roundify_12px.ImageColor3.R)
print(script.Parent.TextButton_Roundify_12px.ImageColor3.G)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("ChangeColor")
function leftClick()
remoteEvent:FireServer(RR,GG,BG)
end
function rightClick()
end
script.Parent.MouseButton1Click:Connect(leftClick)
script.Parent.MouseButton2Click:Connect(rightClick)
Server-side
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("ChangeColor")
local function onChangecolor(player,RR,GG,BB)
print(player.Name .. " Changed the color to" )
print(RR)
print(GG)
print(BB)
print(game.Workspace.Part.Color)
game.Workspace.Part.Color = Color3.fromRGB(RR,BB,GG)
print(game.Workspace.Part.Color)
wait(5)
game.Workspace.Part.Color = Color3.new(RR,BB,GG)
end
remoteEvent.OnServerEvent:Connect(onChangecolor)
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.
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?
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 .
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
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?
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)
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)
end
print(toRGB(Color3.new(1,1,1)) --> 255,255,255