How would I place a gui object in a surface gui depending on where the position from my mouse is?
1 Like
Steps:
- First use
Mouse.Target
in a LocalScript to determine if the mouse is over your part. - 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) - 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
- Those two variables are the scale position of your SurfaceGui