Character doesn't appear!

Hi !
I encountered a strange situation …
When I concatenate this :

BackgroundColor3TextBox.Text = "["..R..", "..G..", "..B.."]"

I get this : "[255, 255, 255"
But I don’t have the last character "]"
Thanks you for the help and have a nice day !

2 Likes
local mycolor = script.Parent.BackgroundColor3


script.Parent.Text = "["..mycolor.R..", "..mycolor.G..", "..mycolor.B.."]"
1 Like

I don’t think you understand what I mean, R, G and B are numbers and I want to concatenate all of these strings and it works the only things is that the "]" doesn’t appear in the text for some reason !

1 Like

Can you please show me the full script so I will understand better?

2 Likes

Ok but I don’t think that will show you something revelant :

BackgroundColor3TextBox.FocusLost:Connect(function()
	local RGB = string.split(BackgroundColor3TextBox.Text, ",")
	if #RGB == 3 then
		local R = math.min(tonumber(RGB[1]), 255)
		local G = math.min(tonumber(RGB[2]), 255)
		local B = math.min(tonumber(RGB[3]), 255)
		local Color = Color3.fromRGB(R, G, B)
		BackgroundColor3TextBox.Text = "["..R..", "..G..", "..B.."]"
		BackgroundColor3TextBox.Parent.Color3Display.BackgroundColor3 = Color
	else
		local Color = BackgroundColor3TextBox.Parent.Color3Display.BackgroundColor3
		local R = math.round(Color.R * 255)
		local G = math.round(Color.G * 255)
		local B = math.round(Color.B * 255)
		BackgroundColor3TextBox.Text = "["..R..", "..G..", "..B.."]"
	end
end)
1 Like

image
your code working fine to me?
try putting a real color3 value over there like 178, 178, 178

2 Likes

Are you putting your text into a text box ?

1 Like

I got this :
image
EDIT : when printed :
image

1 Like

For background color, you need to use a Color3 it does not accept strings. Color3.fromRGB(R, G, B)

2 Likes
BackgroundColor3TextBox.FocusLost:Connect(function()
	local RGB = string.split(BackgroundColor3TextBox.Text, ",")
	if #RGB == 3 then
		local R = math.min(tonumber(RGB[1]), 255)
		local G = math.min(tonumber(RGB[2]), 255)
		local B = math.min(tonumber(RGB[3]), 255)
		local Color = Color3.fromRGB(R, G, B)
		BackgroundColor3TextBox.TextColor3 = Color3.fromRGB(R,G,B)
		BackgroundColor3TextBox.Parent.Color3Display.BackgroundColor3 = Color
	else
		local Color = BackgroundColor3TextBox.Parent.Color3Display.BackgroundColor3
		local R = math.round(Color.R * 255)
		local G = math.round(Color.G * 255)
		local B = math.round(Color.B * 255)
		BackgroundColor3TextBox.TextColor3 = Color3.fromRGB(R,G,B)
	end
end)
2 Likes

the text might be too big? somethings it just dissapears if the text and some space can’t fit inside

2 Likes

It is good I had forgot that I had lines of codes that delete everything that wasn’t a number, a “,” or a space !

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.