Can't preview colour through typing RGB values

Screenshot 2024-04-20 120303

I’m trying to create code where the player enters the Red, Green, and Blue values of a colour and a preview of that colour appears in the white circle on the left. The circle will not change colour regardless of what I put in the textboxes. What can I do to fix this issue?

Change to a Local Script.

2 Likes

Wish you would post code and not pictures. Also need to have your Gui to say for sure where this went wrong. I just made a quick one for it. You may be able to pick out the problem from it.

local player = game.Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")

local screenGui = Instance.new("ScreenGui")
screenGui.Parent = playerGui

local frame = Instance.new("Frame")
frame.Size = UDim2.new(0, 200, 0, 100)
frame.Position = UDim2.new(0.5, -100, 0.5, -50)
frame.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
frame.Parent = screenGui

local redInput = Instance.new("TextBox")
redInput.Size = UDim2.new(0, 60, 0, 20)
redInput.Position = UDim2.new(0.1, 0, 0.1, 0)
redInput.PlaceholderText = "Red"
redInput.Parent = frame

local greenInput = Instance.new("TextBox")
greenInput.Size = UDim2.new(0, 60, 0, 20)
greenInput.Position = UDim2.new(0.1, 0, 0.4, 0)
greenInput.PlaceholderText = "Green"
greenInput.Parent = frame

local blueInput = Instance.new("TextBox")
blueInput.Size = UDim2.new(0, 60, 0, 20)
blueInput.Position = UDim2.new(0.1, 0, 0.7, 0)
blueInput.PlaceholderText = "Blue"
blueInput.Parent = frame

local preview = Instance.new("Frame")
preview.Size = UDim2.new(0, 100, 0, 100)
preview.Position = UDim2.new(0.6, 0, 0, 0)
preview.Parent = frame

local function updatePreview()
	local r = tonumber(redInput.Text) or 0
	local g = tonumber(greenInput.Text) or 0
	local b = tonumber(blueInput.Text) or 0

	preview.BackgroundColor3 = Color3.fromRGB(r, g, b)
end

redInput.FocusLost:Connect(updatePreview)
greenInput.FocusLost:Connect(updatePreview)
blueInput.FocusLost:Connect(updatePreview)
2 Likes

I already found the solution, but thanks though! Also yeah, I should post my script on the post from now on.

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