I picked up this color wheel
local colourWheel = script.Parent:WaitForChild("ColourWheel")
local wheelPicker = colourWheel:WaitForChild("Picker")
local darknessPicker = script.Parent:WaitForChild("DarknessPicker")
local darknessSlider = darknessPicker:WaitForChild("Slider")
local colourDisplay = script.Parent:WaitForChild("ColourDisplay")
local uis = game:GetService("UserInputService")
local buttonDown = false
local movingSlider = false
local active = script.Parent.Parent.Parent.Parent.Properties.CustomColor
local currentColor = Color3.new(1, 1, 1)
local function updateColour(centreOfWheel)
local colourPickerCentre = Vector2.new(
colourWheel.Picker.AbsolutePosition.X + (colourWheel.Picker.AbsoluteSize.X / 2),
colourWheel.Picker.AbsolutePosition.Y + (colourWheel.Picker.AbsoluteSize.Y / 2)
)
local h = (math.pi - math.atan2(colourPickerCentre.Y - centreOfWheel.Y, colourPickerCentre.X - centreOfWheel.X)) / (math.pi * 2)
local s = (centreOfWheel - colourPickerCentre).Magnitude / (colourWheel.AbsoluteSize.X / 2)
local v = math.abs((darknessSlider.AbsolutePosition.Y - darknessPicker.AbsolutePosition.Y) / darknessPicker.AbsoluteSize.Y - 1)
local hsv = Color3.fromHSV(math.clamp(h, 0, 1), math.clamp(s, 0, 1), math.clamp(v, 0, 1))
currentColor = hsv
colourDisplay.ImageColor3 = hsv
darknessPicker.UIGradient.Color = ColorSequence.new{
ColorSequenceKeypoint.new(0, hsv),
ColorSequenceKeypoint.new(1, Color3.new(0, 0, 0))
}
end
colourWheel.MouseButton1Down:Connect(function()
buttonDown = true
end)
darknessPicker.MouseButton1Down:Connect(function()
movingSlider = true
end)
uis.InputEnded:Connect(function(input)
if input.UserInputType ~= Enum.UserInputType.MouseButton1 then return end
buttonDown = false
movingSlider = false
end)
uis.InputChanged:Connect(function(input)
if input.UserInputType ~= Enum.UserInputType.MouseMovement then return end
local mousePos = uis:GetMouseLocation() - Vector2.new(0, game:GetService("GuiService"):GetGuiInset().Y)
local centreOfWheel = Vector2.new(colourWheel.AbsolutePosition.X + (colourWheel.AbsoluteSize.X / 2), colourWheel.AbsolutePosition.Y + (colourWheel.AbsoluteSize.Y / 2))
local distanceFromWheel = (mousePos - centreOfWheel).Magnitude
if distanceFromWheel <= colourWheel.AbsoluteSize.X / 2 and buttonDown then
wheelPicker.Position = UDim2.new(0, mousePos.X - colourWheel.AbsolutePosition.X, 0, mousePos.Y - colourWheel.AbsolutePosition.Y)
elseif movingSlider then
darknessSlider.Position = UDim2.new(darknessSlider.Position.X.Scale, 0, 0,
math.clamp(
mousePos.Y - darknessPicker.AbsolutePosition.Y,
0,
darknessPicker.AbsoluteSize.Y)
)
end
updateColour(centreOfWheel)
end)
local function getRGBColor()
return currentColor
end
game:GetService("RunService").Heartbeat:Connect(function()
if active.Value == true then
script.Parent.Parent.Parent.Parent.Color.Fade.ColorText.Text = "Custom"
active.Parent.Color.Names.Value = "Custom"
active.Parent.Color.Value = getRGBColor()
local R, G, B = active.Parent.Color.Value.R * 255, active.Parent.Color.Value.G * 255, active.Parent.Color.Value.B * 255
R = math.floor(R + 0.5)
G = math.floor(G + 0.5)
B = math.floor(B + 0.5)
local text = script.Parent.TextLabel
text.Text = R .. ", " .. G .. ", " .. B
if R == 3 and G == 3 and B == 3 then
active.Parent.Color.Value = Color3.fromRGB(0, 0, 0)
end
script.Parent.Parent.Parent.Parent.Color.Fade.ColorPreview.BackgroundColor3 = Color3.fromRGB(R, G, B)
end
end)
from a tutorial channel, and I slightly modified it.
Now, right now I am making a system where you can set a part’s properties by just pressing Alt. The issue is though, this uses HSV while my system uses RGB.
How could I convert it, and set the position of the pointer on the colour wheel dynamically as well when setting it?
[When the functions called it sets the CurrentColor property, the position of the dot on the colour wheel and the little slider]