local H=false local W=.01 local A=0 function snap(H,W)if W==0 then return H else return math.floor(H/W+.5)*W end end UIS.InputEnded:connect(function(W,A)if W.UserInputType==Enum.UserInputType.MouseButton1 then H=false end end)SliderBtn.MouseButton1Down:connect(function()H=true end)RuS.RenderStepped:connect(function(T)if H then local H=(UIS:GetMouseLocation()).X local T=SliderBtn.Position local y=Slider.AbsoluteSize.X local G=Slider.AbsolutePosition.X local j=snap((H-G)/y,W)A=math.clamp(j,0,1)SliderBtn.Position=UDim2.new(A,0,T.Y.Scale,T.Y.Offset)end end)
-- Properties
local held = false
local step = 0.010
local percentage = 0

function snap(number, factor)
	if factor == 0 then
		return number
	else
		return math.floor(number / factor + 0.5) * factor
	end
end

UIS.InputEnded:connect(function(input, processed)
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		held = false
	end
end)

SliderBtn.MouseButton1Down:connect(function()
	held = true
end)

RuS.RenderStepped:connect(function(delta)
	if held then
		local MousePos = UIS:GetMouseLocation().X
		local BtnPos = SliderBtn.Position
		local SliderSize = Slider.AbsoluteSize.X
		local SliderPos = Slider.AbsolutePosition.X
		local pos = snap((MousePos - SliderPos) / SliderSize, step)
		percentage = math.clamp(pos, 0, 1)
		SliderBtn.Position = UDim2.new(percentage, 0, BtnPos.Y.Scale, BtnPos.Y.Offset)
	end
end)
