RGB Values being printed in wrong format

I have a seat in a game, and when the player sits in that seat, this script detects that, GetsPlayerFromCharacter, goes into PlayerGui where the player can change the settings of the color in RGB values, and it is supposed to update the color of a part to match the RGB values in player settings.

However, I’ve been having problems with the color not matching the values in player settings, so I set up print() functions to see where the problem was coming from. I then realized that when I printed the BackgroundColor3 of the item, the print result was in x / 255, so since the BackgroundColor3 value was 255, 255, 255 (white) the print result was 1, 1, 1. For this reason, the part color was changed to black.

Why is this? Why were the results printed in ratios of 255? Is there a way I can go around this in order to print out their real RGB values? (i.e, a print result of 255, 255, 255 so that the right color is used to change the color of the part)

I can use BrickColor in order to change to the correct color, but I was just wondering why this is.

Thanks for all of the help.

local seat = workspace.lead["lead seat"]
seat:GetPropertyChangedSignal("Occupant"):Connect(function()
	if seat.Occupant ~= nil then
		local occupant = seat.Occupant.Parent
		local occupantCharacter = game.Players:GetPlayerFromCharacter(occupant)
		print(occupant.ClassName)
		print(occupantCharacter.ClassName)
		print(occupantCharacter.PlayerGui.settings.Frame.colorIndicator.BackgroundColor3)
		script.Parent.Color = Color3.fromRGB(occupantCharacter.PlayerGui.settings.Frame.colorIndicator.BackgroundColor3)
	end
end)

is this a local script ?

No, it’s a server script. I wanted the changed color to be visible to everybody in-game.

ig that’s the issue, you have used a server script…
instead try to get the color from the local script and send it to server via remote event and then change.

or even better would be this
server script:

local seat = workspace.lead["lead seat"]
seat:GetPropertyChangedSignal("Occupant"):Connect(function()
	if seat.Occupant ~= nil then
		local occupant = seat.Occupant.Parent
		local occupantCharacter = game.Players:GetPlayerFromCharacter(occupant)
		script.Parent.Color = Color3.fromRGB(RemoteFunction:InvokeClint(occupantCharacter))
	end
end)

Local Script

RemoteFunction.OnClientInvoke = function()
return game.Players.LocalPlayer.PlayerGui.settings.Frame.colorIndicator.BackgroundColor3
end

Because you are telling the code to create a Color3 Value using another Color3 Value, Color3 takes in 3 arguments, and the Color3 would only be providing for 1 of the Arguments, it wont accept that value so it will default to black, Instead just add the color like so:

script.Parent.Color = occupantCharacter.PlayerGui.settings.Frame.colorIndicator.BackgroundColor3

Just Multiply the Value by 255 and round it if you want to get the exact RGB Value

math.round(x*255) -- should be our RGB Value
1 Like