Make Gui Object From A Surface Gui Position Exactly Where The Player Mouse Position Is?

How would I place a gui object in a surface gui depending on where the position from my mouse is?

1 Like

Steps:

  1. First use Mouse.Target in a LocalScript to determine if the mouse is over your part.
  2. Next, use Mouse.Hit.Position to determine the 3D position of the mouse.
    (If you want the SurfaceGui to be affected server-wide, use a RemoteEvent to trigger the event; otherwise, use a LocalScript in StarterPlayerScripts)
  3. Assuming your part isn’t rotated, find out the relative location like so:
    a. local X = (Mouse.Hit.Position.X - Part.Position.X - (Part.Size.X / 2)) / Part.Size.X
    b. local Y = (Mouse.Hit.Position.Y - Part.Position.Y - (Part.Size.Y / 2)) / Part.Size.Y
  4. Those two variables are the scale position of your SurfaceGui :+1: