How to move a gui to the mouse's position without it being cut off

I’m looking to move a UI element with the mouse, however I’m not sure how to prevent it from being cut off by the edge of the screen.

Here’s a video with the problem:

Here’s my current code:

element.Visible = true
element.Position = UDim2.new(0, Mouse.X, 0, Mouse.Y)
1 Like

Check the TextBounds as compared to the AbsoluteSize & AbsolutePosition.

How could I go about doing this with a frame as well?