Need help with rgb wave glitch

Hi,

I have a color wheel but if I turn on rgb while its in a dark/light area for instance white or black the rgb won’t work, my guess is it can’t read the color, I don’t really know.

Any help is appreciated!

Video:

Script:

local localPlayer = game.Players.LocalPlayer
local Mouse = localPlayer:GetMouse()

local RGB = script.Parent:WaitForChild("RGB")
local Value = script.Parent:WaitForChild("Value")
local Preview = script.Parent:WaitForChild("Preview")
local RGBButton = script.Parent.Parent.Frame.Info:WaitForChild("RGB")

local selectedColor = Color3.fromHSV(1, 1, 1)
local colorData = {1, 1, 1}

local mouse1Down = false
local waveActive = false

local function setColor(hue, sat, val)
	colorData = {hue or colorData[1], sat or colorData[2], val or colorData[3]}
	selectedColor = Color3.fromHSV(colorData[1], colorData[2], colorData[3])
	Preview.BackgroundColor3 = selectedColor
	Value.ImageColor3 = Color3.fromHSV(colorData[1], colorData[2], 1)
end

local function inBounds(frame)
	local x, y = Mouse.X - frame.AbsolutePosition.X, Mouse.Y - frame.AbsolutePosition.Y
	local maxX, maxY = frame.AbsoluteSize.X, frame.AbsoluteSize.Y
	if x >= 0 and y >= 0 and x <= maxX and y <= maxY then
		return x / maxX, y / maxY
	end
end

local function updateRGB()
	if mouse1Down then
		waveActive = false
		local X, Y = inBounds(RGB)
		if X and Y then
			RGB:WaitForChild("Marker").Position = UDim2.new(X, 0, Y, 0)
			setColor(X, 1 - Y, colorData[3])
			print("RGB updated: X =", X, "Y =", Y)
		end

		local X, Y = inBounds(Value)
		if X and Y then
			Value:WaitForChild("Marker").Position = UDim2.new(0.5, 0, Y, 0)
			setColor(colorData[1], colorData[2], 1 - Y)
			print("Value updated: X =", X, "Y =", Y)
		end
	end
end

script.Parent.Info.Apply.MouseButton1Down:Connect(function()
	local color = script.Parent.Preview.BackgroundColor3
	if not waveActive then
		game.ReplicatedStorage.RemoteEvents.AdrenalineColorEvent:FireServer(color)
	end
end)

Mouse.Move:Connect(updateRGB)
Mouse.Button1Down:Connect(function() 
	mouse1Down = true 
end)
Mouse.Button1Up:Connect(function() 
	mouse1Down = false 
end)

local function startRGBWave()
	waveActive = not waveActive
	if waveActive then
		spawn(function()
			while waveActive do
				for hue = 0, 1, 0.01 do
					if not waveActive then break end
					setColor(hue, colorData[2], colorData[3])
					wait(0.1)
					game.ReplicatedStorage.RemoteEvents.AdrenalineColorEvent:FireServer(selectedColor)
				end
			end
		end)
	end
end

RGBButton.MouseButton1Down:Connect(startRGBWave)

Ignore the wheel color not matching, I fixed that portion