How would I make the circle stop moving onto the bars on the screen and make the system more forgiving

Once again I am here to ask for your support.

I seem to have achieved such a small issue, but at doing two things. Once the Mouse leaves the gui, I want the gui to stop moving, and I want circle to go back in it’s original position, or even in a random position, just not moving around.

-- \\ Variables // --

local Randomzier = Random.new()

local Meditation = Instance.new("BoolValue")

Meditation = false

local GUIS = script.Parent

local Circle = GUIS.MovingCircle

-- \\ Services/Service-Related Variables // --

local UIS = game:GetService("UserInputService")

local TW = game:GetService("TweenService")

local RSR = game:GetService("RunService")

local RS = game:GetService("ReplicatedStorage")

local Med = RS:FindFirstChild("Meditation")

local MouseLoc = UIS:GetMouseLocation()
-- \\ Functions // --

GUIS.IgnoreGuiInset = true


UIS.InputBegan:Connect(function(Input, Processed, IsTyping)
	if not IsTyping then
		

		if Input.KeyCode == Enum.KeyCode.M then
			
						
			if GUIS.Enabled == false then 
			
				
				GUIS.Enabled = true

				
				Circle.MouseEnter:Connect(function()
					print("We working")
				
					while GUIS.Enabled do
						wait(1)
						local LOL = script.Parent.MovingCircle:TweenPosition(
							UDim2.new(Randomzier:NextNumber(0, 0.962),0 ,Randomzier:NextNumber(0, 0.285),0),
							Enum.EasingDirection.Out,
							Enum.EasingStyle.Linear,
							3,
							false,
							nil
						)
						
						
						wait(1)
					
					end


				end)

				Circle.MouseLeave:Connect(function()

					GUIS.Enabled = false
					Meditation = false

				end)
			end





		end
	end

end)
	

( Update, never mind. The tween does stop, but not immediately)

The other issue I was having is resolved, so I’m going onto a new issue. I want to stop my ball from going onto the other parts of my gui but it’ll do that regardless of where I limit it to via my code.

When tweening the position you will need to offset the position using the size of the ball to limit the bounds of the position. Maybe get the bottom right/left corner as an offset.

Well, I did that and it started going off screen.