Interact with objects in a viewportframe

  1. What do you want to achieve? be able to interact with objects in a viewportframe like be able to click it then it will show you what is it

  2. What is the issue? I have no idea on how to do such things.

  3. What solutions have you tried so far? i tried adding click detectors on the part and surface gui buttons

All i want to know is how to be able to click it on the viewportframe.

Put a 2D button on top the Viewport.

Also, please be aware that the DevForum members will not make an entire script for you, unless it’s for your better understanding.

Lets say I have a minimap using viewportframes that follows my player. Are you saying that I add a 2d button on the middle of the minimap?

Yes, that is one way of doing it.

Any other ways? Because the player is not the only thing i want to interact with

Well, I don’t think so, not without super complicated code (math and such). ViewportFrame is a UI that renders a camera, and it’s not a second interactable workspace. UI is your only way for this to work.

You other method would be to convert the objects in the frame to 2D relative position, and then get the player mouse click event and mouse relative position.

if i understand correctly, You want to be able click/hover over objects in viewportframes, right? One way you can do that is use the method i described here: (there is a place file at the bottom)

Or alternatively this module Onogork made:


Btw, at some point this will become easier when worldmodels are released, which will allow us to natively ray cast in viewportframes. (supposedly)

1 Like