So, if anyone used Microsoft Paint and click Edit Colors, theres a menu to create any color you want. So, I'm trying to recreate that. I tried making a text box to display the current RGB value and HSL value. Here is what I decided
local color = script.Parent.Parent.Parent.CurrentColor local r, g, b = color.Value.r * 255, color.Value.g * 255, color.Value.b * 255 script.Parent.R.TextBox.Text = r script.Parent.G.TextBox.Text = g script.Parent.B.TextBox.Text = b wait() color.Changed:Connect(function() local f = math.floor local r, g, b = color.Value.r * 255, color.Value.g * 255, color.Value.b * 255 script.Parent.R.TextBox.Text = f(r) script.Parent.G.TextBox.Text = f(g) script.Parent.B.TextBox.Text = f(b) end) local inputs = { script.Parent.R.TextBox; script.Parent.G.TextBox; script.Parent.B.TextBox } wait(.1) for _, inputs in pairs(inputs) do local prev = inputs.Text local deb = false inputs.Changed:Connect(function() if not deb then deb = true local txt = require(script.Parent.Parent.Parent.NumConstrain):Constrain(prev, inputs.Text) if txt then if tonumber(txt) then inputs.Text = math.floor(string.sub(txt, 1, 3)) end local n = tonumber local r, g, b = n(script.Parent.R.TextBox.Text) or 0, n(script.Parent.G.TextBox.Text) or 0, n(script.Parent.B.TextBox.Text) or 0 color.Value = Color3.fromRGB(r, g, b) else inputs.Text = txt end wait() deb = false end end) end
You don't need to worry about the requiring though, it is just to keep the text in the textbox a number from 0 to 255 with no letters.
However, when I click play, I go into the explorer and get my CurrentColor value. I change it to 0, 0, 0 in the little pop up when you edit colors, and the properties in the CurrentColor value say 2, 2, 0 and my display says 2, 2, 2. Also, my HSL display for the color is wrong too with 120, 255, 255 in the popup and 85, 255, 255 in the display. Is this a roblox bug, or what did I do terribly wrong with my code?