So recently I attempted to follow a tutorial that showed how to make a gui slider, however the tutorial moved the slider via position instead of size.
I tried to tweak it to how I am doing mine (by expanding the size) but whenever I do, it does this weird thing and bugs out.
Code:
slider.SliderButton.MouseButton1Down:Connect(function()
Dragging = true
end)
UIS.InputChanged:Connect(function()
if Dragging then
local MousePos = UIS:GetMouseLocation()+Vector2.new(0,36)
local relPos = MousePos - slider.SliderButton.AbsolutePosition
local percent = math.clamp(relPos.X/slider.SliderButton.AbsoluteSize.X,0, 1)
slider.SliderButton.Size = UDim2.new(percent, 0, 0, 16)
print(percent*100)
end
end)
UIS.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
Dragging = false
end
end)
SliderButton is the button I use for both pressing the slider and expanding it (let me know if i should change that)
As shown in the video, it appears that the percent is constantly going back to 100.
If anybody experienced with this could reply hopefully explaining how it works and how to fix it would be amazing.