Don’t know why vector2 was expected or what that means but I need help with my script.
Error code:
Players.militry22q.PlayerGui.RGBColorPicker.Base.SliderGui.RedBar.SliderHandler:24: invalid argument #1 (Vector2 expected, got number)
My Code:
local UIS = game:GetService("UserInputService")
local sliderFrame = script.Parent
local sliderButton = sliderFrame.Slider
local sliderDisplay = sliderFrame.SliderValue
local sliderDragging = false
sliderButton.MouseButton1Down:Connect(function()
sliderDragging = true
end)
UIS.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
sliderDragging = false
end
end)
UIS.InputChanged:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseMovement then
if sliderDragging == true then
local mouseLoc = UIS:GetMouseLocation()
local abs_size = sliderFrame.AbsoluteSize
local abs_pos = sliderFrame.AbsolutePosition
local max = abs_pos.X + (abs_size * .5)
local min = abs_pos.X - (abs_size * .5)
local percentage = math.clamp((max - mouseLoc.X)/(max - min), 0, 1)
sliderButton.Position = UDim2.new(percentage,0,0.5,0)
sliderDisplay.Text = ("%.0f"):format(sliderButton.Position * 255)
end
end
end)
Please help me. Thank you