------[RGB_SLIDER_MOVEMENT, RGB_TEXT_CHANGED]------

for z = 1, #ColorPickers do
	for i = 1, #RGBSliders[z] do
		----[STOP RGB SLIDER MOVEMENT]----
		local function RGBSliderEnded(Input)
			if Input.UserInputType == Enum.UserInputType.MouseButton1 then
				IsDraggingSliders[i] = false
			end
		end
		RGBSliderHitboxes[z][i].InputEnded:Connect(RGBSliderEnded)
		
		----[CHECK FOR RGB SLIDER MOVEMENT]----
		local function CheckForRGBSliderMovement()
			if not IsDraggingSliders[i] then
				IsDraggingSliders[i] = true
			end	
			while IsDraggingSliders[i] do--and UIS:IsMouseButtonPressed(Enum.UserInputType.MouseButton1) do
				wait()
				local MouseLocation = Plugin:GetRelativeMousePosition()
				if OldMouseLocation ~= MouseLocation then
					RGBSliderMovement(MouseLocation.X, z, i)
					OldMouseLocation = MouseLocation
				end
			end
			IsDraggingSliders[i] = false
		end
		RGBSliderHitboxes[z][i].MouseButton1Down:Connect(CheckForRGBSliderMovement)
		
		----[CHECK IF RGB TEXT CHANGED]----
		local function RGBTextChanged()
			if tonumber(RGBInputs[z][i].Text) == nil then
				RGBInputs[z][i]. Text = "0"
			elseif tonumber(RGBInputs[z][i].Text) <= 0 then
				RGBInputs[z][i].Text = "0"
			elseif tonumber(RGBInputs[z][i].Text) >= 256 then
				RGBInputs[z][i].Text = "255"	
			end
			
			PreviewColor[z].BackgroundColor3 = Color3.fromRGB(tonumber(RGBInputs[z][1].Text), tonumber(RGBInputs[z][2].Text), tonumber(RGBInputs[z][3].Text))
			RGBSliders[z][i].Position = UDim2.new(0, PreviewColor[z].BackgroundColor3[rgb[i]] * RGBSliderHitboxes[z][i].AbsoluteSize.X, RGBSliders[z][i].Position.Y.Scale, 0)
			end
		RGBInputs[z][i].FocusLost:Connect(RGBTextChanged)
	end
end

