client,service=nil,nil return function(O,g)if g then setfenv(1,g)end local Y=O.Color or Color3.new(1,1,1)local M,D,k=Y.r,Y.g,Y.b local h,X,z local l,G,A local J,s,d local u=25 local Q local Z local f=client.UI.Make("\087\105\110\100\111\119",{Name="\067\111\108\111\114\080\105\099\107\101\114",Title=O.Title or"\067\111\108\111\114 \080\105\099\107\101\114",Icon=client.MatIcons.Create;Size={250,230},MinSize={150;230},MaxSize={math.huge;230},SizeLocked=true,OnClose=function()if not Q then Q=Y end end})local c=f:Add("\070\114\097\109\101",{Size=UDim2.new(1,-10,0,u-5);Position=UDim2.new(0,5,0,u*6);BackgroundColor3=Y})local m=f:Add("\084\101\120\116\066\117\116\116\111\110",{Text="\065\099\099\101\112\116";Size=UDim2.new(1,-10,0,u-5);Position=UDim2.new(0,5,0,u*7);Events={MouseButton1Down=function()Q=Y f:Close()end}})local function R()Y=Color3.new(M,D,k)c.BackgroundColor3=Y l:SetValue(math.floor(M*255))J.Color=ColorSequence.new(Color3.new(0,D,k),Color3.new(1,D,k))h:SetValue(M)G:SetValue(math.floor(D*255))s.Color=ColorSequence.new(Color3.new(M,0,k),Color3.new(M,1,k))X:SetValue(D)A:SetValue(math.floor(k*255))d.Color=ColorSequence.new(Color3.new(M,D,0),Color3.new(M,D,1))z:SetValue(k)end l=f:Add("\083\116\114\105\110\103\069\110\116\114\121",{Text="\082\101\100\058 ",BoxText=M*255;BackgroundTransparency=1,TextSize=20;Size=UDim2.new(1,-20,0,u-5),Position=UDim2.new(0,10,0,u*0),TextChanged=function(O,g,Y)if tonumber(O)then local g O=math.floor(tonumber(O))if O<0 then g=true O=0 elseif O>255 then g=true O=255 end M=O/255 R()if g then return O end elseif g then return M*255 end end})G=f:Add("\083\116\114\105\110\103\069\110\116\114\121",{Text="\071\114\101\101\110\058 ",BoxText=D*255;BackgroundTransparency=1;TextSize=20;Size=UDim2.new(1,-20,0,u-5);Position=UDim2.new(0,10,0,u*2);TextChanged=function(O,g,Y)if tonumber(O)then local g=false O=math.floor(tonumber(O))if O<0 then g=true O=0 elseif O>255 then g=true O=255 end D=O/255 R()if g then return O end elseif g then return D*255 end end})A=f:Add("\083\116\114\105\110\103\069\110\116\114\121",{Text="\066\108\117\101\058 ",BoxText=k*255;BackgroundTransparency=1,TextSize=20,Size=UDim2.new(1,-20,0,u-5);Position=UDim2.new(0,10,0,u*4);TextChanged=function(O,g,Y)if tonumber(O)then local g=false O=math.floor(tonumber(O))if O<0 then g=true O=0 elseif O>255 then g=true O=255 end k=O/255 R()if g then return O end elseif g then return k*255 end end})h=f:Add("\083\108\105\100\101\114",{Percent=Y.r;Size=UDim2.new(1,-20,0,u-5),Position=UDim2.new(0,10,0,u*1),OnSlide=function(O)M=O R()end})X=f:Add("\083\108\105\100\101\114",{Percent=Y.r;Size=UDim2.new(1,-20,0,u-5),Position=UDim2.new(0,10,0,u*3);OnSlide=function(O)D=O R()end})z=f:Add("\083\108\105\100\101\114",{Percent=Y.r;Size=UDim2.new(1,-20,0,u-5);Position=UDim2.new(0,10,0,u*5);OnSlide=function(O)k=O R()end})J=service.New("\085\073\071\114\097\100\105\101\110\116",h.SliderBar)s=service.New("\085\073\071\114\097\100\105\101\110\116",X.SliderBar)d=service.New("\085\073\071\114\097\100\105\101\110\116",z.SliderBar)R()Z=f.gTable f:ResizeCanvas()f:Ready()repeat task.wait()until Q or not Z.Active return Q end
client, service = nil, nil

return function(data, env)
	if env then
		setfenv(1, env)
	end
	
	local color = data.Color or Color3.new(1, 1, 1)
	local red, green, blue = color.r, color.g, color.b
	local redSlider, greenSlider, blueSlider
	local redBox, greenBox, blueBox
	local redGradient, greenGradient, blueGradient
	local ySize = 25
	local returnColor
	local gTable
	
	local window = client.UI.Make("Window", {
		Name  = "ColorPicker";
		Title = data.Title or "Color Picker";
		Icon = client.MatIcons.Create;
		Size  = {250,230};
		MinSize = {150, 230};
		MaxSize = {math.huge, 230};
		--Position = UDim2.new(0, 10, 1, -80);
		SizeLocked = true;
		OnClose = function()
			if not returnColor then
				returnColor = color
			end
		end
	})
	
	local colorBox = window:Add("Frame", {
		Size = UDim2.new(1, -10, 0, ySize-5);
		Position = UDim2.new(0, 5, 0, ySize*6);
		BackgroundColor3 = color;
	})
	
	local okButton = window:Add("TextButton", {
		Text = "Accept";
		Size = UDim2.new(1, -10, 0, ySize-5);
		Position = UDim2.new(0, 5, 0, ySize*7);
		Events = {
			MouseButton1Down = function()
				returnColor = color
				window:Close()
			end
		}
	})
	
	local function updateColors()
		color = Color3.new(red, green, blue)
		colorBox.BackgroundColor3 = color
		
		redBox:SetValue(math.floor(red*255))
		redGradient.Color = ColorSequence.new(Color3.new(0,green,blue),Color3.new(1,green,blue))
		redSlider:SetValue(red)
		
		greenBox:SetValue(math.floor(green*255))
		greenGradient.Color = ColorSequence.new(Color3.new(red,0,blue),Color3.new(red,1,blue))
		greenSlider:SetValue(green)
		
		blueBox:SetValue(math.floor(blue*255))
		blueGradient.Color = ColorSequence.new(Color3.new(red,green,0),Color3.new(red,green,1))
		blueSlider:SetValue(blue)
	end
	
	redBox = window:Add("StringEntry", {
		Text = "Red: ";
		BoxText = red*255;
		BackgroundTransparency = 1;
		TextSize = 20;
		Size = UDim2.new(1, -20, 0, ySize-5);
		Position = UDim2.new(0, 10, 0, ySize*0);
		TextChanged = function(newText, focusLost, enterPressed)
			if tonumber(newText) then
				local doRet
				newText = math.floor(tonumber(newText))
				if newText < 0 then
					doRet = true
					newText = 0
				elseif newText > 255 then
					doRet = true
					newText = 255
				end
				
				red = newText/255
				updateColors()
				if doRet then return newText end
			elseif focusLost then
				return red*255
			end
		end;
	})
	
	greenBox = window:Add("StringEntry", {
		Text = "Green: ";
		BoxText = green*255;
		BackgroundTransparency = 1;
		TextSize = 20;
		Size = UDim2.new(1, -20, 0, ySize-5);
		Position = UDim2.new(0, 10, 0, ySize*2);
		TextChanged = function(newText, focusLost, enterPressed)
			if tonumber(newText) then
				local doRet = false
				newText = math.floor(tonumber(newText))
				if newText < 0 then
					doRet = true
					newText = 0
				elseif newText > 255 then
					doRet = true
					newText = 255
				end
				
				green = newText/255
				updateColors()
				if doRet then return newText end
			elseif focusLost then
				return green*255
			end
		end;
	})
	
	blueBox = window:Add("StringEntry", {
		Text = "Blue: ";
		BoxText = blue*255;
		BackgroundTransparency = 1;
		TextSize = 20;
		Size = UDim2.new(1, -20, 0, ySize-5);
		Position = UDim2.new(0, 10, 0, ySize*4);
		TextChanged = function(newText, focusLost, enterPressed)
			if tonumber(newText) then
				local doRet = false
				newText = math.floor(tonumber(newText))
				if newText < 0 then
					doRet = true
					newText = 0
				elseif newText > 255 then
					doRet = true
					newText = 255
				end
				
				blue = newText/255
				updateColors()
				if doRet then return newText end
			elseif focusLost then
				return blue*255
			end
		end;
	})
	
	redSlider = window:Add("Slider", {
		Percent = color.r;
		Size = UDim2.new(1, -20, 0, ySize-5);
		Position = UDim2.new(0, 10, 0, ySize*1);
		OnSlide = function(value)
			red = value
			updateColors()
		end
	})
	
	greenSlider = window:Add("Slider", {
		Percent = color.r;
		Size = UDim2.new(1, -20, 0, ySize-5);
		Position = UDim2.new(0, 10, 0, ySize*3);
		OnSlide = function(value)
			green = value
			updateColors()
		end
	})
	
	blueSlider = window:Add("Slider", {
		Percent = color.r;
		Size = UDim2.new(1, -20, 0, ySize-5);
		Position = UDim2.new(0, 10, 0, ySize*5);
		OnSlide = function(value)
			blue = value
			updateColors()
		end
	})
	
	redGradient = service.New("UIGradient", redSlider.SliderBar)
	greenGradient = service.New("UIGradient", greenSlider.SliderBar)
	blueGradient = service.New("UIGradient", blueSlider.SliderBar)
	
	updateColors()
	gTable = window.gTable
	window:ResizeCanvas()
	window:Ready()
	
	repeat
		task.wait()
	until returnColor or not gTable.Active
	
	return returnColor
end
