Is it possible to show BillboardGui at mouse location?

I’m trying to create an interaction similar to the one seen in Welcome to Bloxburg, where when you click on a surface an interaction button shows up exactly where you clicked on that surface, and stays like a BillboardGui on that surface as you move your camera.

I’m not sure if Bloxburg uses BillboardGuis to achieve this effect, but I’ve gotten part of the way there using them.

Bloxburg’s system:

Currently, I’ve got my system setup to show a BillboardGui on the part that is clicked, and that’s working as expected. However, since it’s a BillboardGui, the button shows at the center of the part rather than where I clicked.

I want it to show relative to where the player clicked on the part, so I’m not sure if this can be achieved with a BillboardGui or if I’d have to create the buttons in a ScreenGui and update their positions according to how the camera moves (sounds like much more of a challenge than just showing the billboard).

My current system:

If anyone has created similar systems or has an idea of how to create a similar system to the one seen in Bloxburg, your insight is appreciated.

Thanks in advance :slight_smile:

There is a built-in function called WorldToScreenPoint which does exactly that

Actually, I think they try to do the reverse of that, convert screen coordinates to world coordinates.

Edit 2: Also since an extra dimension is introduced to the thing I assume you must cast a ray from the camera all the way forward until it hits the object to fetch the extra dimension.

Edit 3: Aight I’m dumb just use Mouse.Hit :skull:

Mouse.Hit should give you the world coordinate of the position that is being pointed.
Mouse.Target should give you the targeted object.

So to show a BillboardGui at the position given by Mouse.Hit, would you suggest setting its Adornee as the part and then messing about with the StudsOffset until it’s where the mouse is, or creating a new part at the location and setting the Adornee to that part instead?

I would say either would work.
Creating a part is simple.
However, it is also not that much work to have mouse.Hit-mouse.target.Position for you to get the offset

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.