Hi,
So I’ve made a colour wheel and I want to make the wheel return the correct wheel depending on what angle the mouse is from the centre of the circle. So far I have this:
mouse.Move:Connect(function()
local x, y = mouse.X, mouse.Y
local cursorVector = Vector2.new(x, y) - script.Parent.AbsolutePosition - (script.Parent.AbsoluteSize * script.Parent.AnchorPoint)
local unit = cursorVector.Unit * script.Parent.AbsoluteSize.Y
local anchorPointFactor = script.Parent.AbsoluteSize * script.Parent.AnchorPoint
script.Parent.Frame.Position = UDim2.fromScale(unit.X / script.Parent.AbsoluteSize.X + script.Parent.AnchorPoint.X, unit.Y / script.Parent.AbsoluteSize.Y + script.Parent.AnchorPoint.Y)
local angle = math.deg(math.atan2(cursorVector.Y, cursorVector.X))
local hueAngle = (angle) / 360
local hue = hueAngle
script.Parent.Frame.BackgroundColor3 = Color3.fromHSV(hue,1,1)
end)
However, when it reaches hueAngle = angle / 360, that’s where the issue stems from.
It works fine for the bottom half of the circle,
But the top half returns black
I’ve tried:
math.abs, subtracting 1 then math.abs, adding 0.5, adding 1, etc but they all seem to result in the colour either being inverted from top to bottom, or inverted from left to right. Any help?