How to make a viewport frame able to detect clicks

I need to detect when the mouse is clicking on a viewport frame. How can I achive this?

1 Like
viewportframe.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
print('hi')
end
end)
1 Like

You can add a textbutton to the ViewPortFrame. Set the size to 1, 1 (Scale)
and set the backgroundtransparency and texttransparency to 1.

And then the code:

ViewPortFrame.TextButton.MousButton1Click:Connect(function()
   --Your Code here
end)

If there’s an error let me know. :grin: