Gui glitches out like crazy when sliding, how to fix?

I have a gui slider that goes up and down, I DON’T WANT TO USE SCROLLING FRAME DONT SUGGEST IT PLEASE. And im using this simple line, that in theory should work:

repeat
	wait()
	script.Parent.Position = UDim2.new(0.5,0,0,mouse.Y-script.Parent.AbsolutePosition.Y)
until pulling == false

the anchor point is 0.5,0
and for some reason it glitches out like:

does anyone know what is going on and how to fix it? this is the entire script:

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

local pulling = false
mouse.Button1Down:Connect(function()
	local x = mouse.X
	local y = mouse.Y
	local minX,maxX = script.Parent.AbsolutePosition.X,script.Parent.AbsolutePosition.X+(script.Parent.AbsoluteSize.X)
	local minY,maxY = script.Parent.AbsolutePosition.Y,script.Parent.AbsolutePosition.Y+script.Parent.AbsoluteSize.Y
	if x >= minX and x <= maxX and y >= minY and y <= maxY then
		pulling = true
		
		repeat
			wait()
			script.Parent.Position = UDim2.new(0.5,0,0,mouse.Y-script.Parent.AbsolutePosition.Y)
		until pulling == false
	else
		--
	end
end)
mouse.Button1Up:Connect(function()
	pulling = false
end)

the only issue i have is with the positioning, everything else works perfectly as I intended

Try using TweenService if you know how to use it.

You can use this to move GUI objects GuiObject:TweenPosition()

As I expected thats just making the bugging out more smooth. Its just animating it going to the top of the screen to the mouse and repeating it until i stop pulling.