I am attempting to make an HSV color changer and for some reason whenever I pop open my UI the top hue and saturation slider goes insanely fast when switching colors. However, when i changed my Value slider at the bottom the code works fine and it is no longer is fast. Here is a video of it in action.
here is the code for hue and saturation
DressUpUI.DressUpColoring.ColorPicking.MainColorPicking.HueSatPick.ColorSelector.MouseButton1Click:Connect(function()
local function updateHueSat()
local x = (UserInputService:GetMouseLocation().X - MainColorPicking.HueSatPick.AbsolutePosition.X - GuiService:GetGuiInset().X) / MainColorPicking.HueSatPick.AbsoluteSize.X
local y = (UserInputService:GetMouseLocation().Y - MainColorPicking.HueSatPick.AbsolutePosition.Y - GuiService:GetGuiInset().Y) / MainColorPicking.HueSatPick.AbsoluteSize.Y
local xClamped = math.clamp(x, 0, 1)
local yClamped = math.clamp(y, 0, 1)
MainColorPicking.HueSatPick.ColorSelector.Position = UDim2.fromScale(xClamped, yClamped)
Hue = xClamped
Saturation = 1 - yClamped
updateHSV()
end
if isSelectorActive then
isSelectorActive = false
RunService:UnbindFromRenderStep("updateHueSat")
UserInputService.MouseIconEnabled = true
else
UserInputService.MouseIconEnabled = false
RunService:BindToRenderStep("updateHueSat", Enum.RenderPriority.Camera.Value + 1, updateHueSat)
isSelectorActive = true
end
end)
here is the code for Value
local function updateValue()
local x = (UserInputService:GetMouseLocation().X - MainColorPicking.ValuePick.AbsolutePosition.X - GuiService:GetGuiInset().X) / MainColorPicking.ValuePick.AbsoluteSize.X
local y = (UserInputService:GetMouseLocation().Y - MainColorPicking.ValuePick.AbsolutePosition.Y - GuiService:GetGuiInset().Y) / MainColorPicking.ValuePick.AbsoluteSize.Y
local xClamped = math.clamp(x, 0, 1)
local yClamped = math.clamp(y, 0, 1)
MainColorPicking.ValuePick.ColorSelector.Position = UDim2.fromScale(xClamped, yClamped)
Value = 1 - xClamped
updateHSV()
end
if isSelectorActive then
isSelectorActive = false
UserInputService.MouseIconEnabled = true
RunService:UnbindFromRenderStep("colorUpdate")
else
UserInputService.MouseIconEnabled = false
RunService:BindToRenderStep("colorUpdate", Enum.RenderPriority.Camera.Value + 1, updateValue)
isSelectorActive = true
end
end)
I apologize for the horrendous character model. I just slapped some things on for testing purposes.