How to make GUI follow Mouse on click but stop after another click

Hey there,

I want to create a GUI that when i click it, it will follow the player’s mouse and when the player clicks again, it will stop moving. How can i achieve this?

Here’s my code that i already have:

local player = game.Players.LocalPlayer

local mouse = player:GetMouse()

script.Parent.Mover.MouseButton1Click:Connect(function()

repeat

script.Parent.Position = UDim2.new(0, ((mouse.X)-90), 0, ((mouse.Y)-20))

until script.Parent.Mover.MouseButton1Click

end)

What is erroring. We can’t help until we KNOW THE ISSUE!

local player = game.Players.LocalPlayer

local mouse = player:GetMouse()

script.Parent.Mover.MouseButton1Click:Connect(function()

repeat

script.Parent.Position = UDim2.new(0, ((mouse.X)-90), 0, ((mouse.Y)-20))

until mouse.MouseButton1Down

end)

try that

It’s odd, whenever i try either one of these, it makes the GUI invisible but i know it is there because my cursor goes black. It is also not printing out any errors in the output?