Button sets itself into weird position while dragging it

if you look at that the circle passes over the grey line

if you cant understand it here

here is the code

Slider.MouseButton1Up:Connect(function()
	MovingSlider = true
end)

Slider.MouseButton1Up:Connect(function()
	MovingSlider = true
end)

-- Button Functions
Mouse.Button1Up:Connect(function()
	
	MovingSlider = true
end)

Mouse.Move:Connect(function()
	if MovingSlider then
		
		local offsetY = math.floor((Mouse.X - Circle.AbsolutePosition.Y) / snapAmount + .5) * snapAmount
		local offsetYclamped = math.clamp(offsetY, pixelsfromEdge, Slider.AbsoluteSize.Y - pixelsfromEdge)
		
		local CircleNewPos = UDim2.new(-1.485,0,Circle.Position.Y, offsetY)
		
		Circle.Position = CircleNewPos
	end
end)

i got it from a tutorial but the tutorial was different so i tried making my own one but it didnt work well

and how can i make sure that dragging only works when the mouse is touching the button

how it works basically is a dragging up and down ui but the problem is when i try dragging it up and down its position is weird

hello please help me? i need help for now im gonna work on something else