Getting part position clicking on it inside a ViewPortFrame?

Hello guys! it’s my first time creating a topic on dev forum because I really couldn’t find the solution for my issue, ok, here I go.
I know that I can’t access the Part because viewport is to display 3D objects within 2D UI. There is a way to access the Parts inside a ViewPortFrame clicking on it?

There is an example:

    local player = game.Players.LocalPlayer
    local mouse = player:GetMouse()
    local viewPort =script.Parent:WaitForChild('ViewportFrame')
    
    --Create Camera
    local camera = Instance.new("Camera", script.Parent)
    camera.CameraType = Enum.CameraType.Fixed
    camera.Name = 'MinimapCamera'
    viewPort.CurrentCamera = camera
    camera.CFrame = CFrame.new(Vector3.new(0,335,0), Vector3.new(0,0,0))

    -- My Problem is here, how can I access it?
    viewPort.Space.Base.ClickDetector.MouseClick:Connect(function()
    print(mouse.X..', '..mouse.Y) 
    end)

What I’m trying to do is a MiniMap, I want to get the position of the Base using ClickDectector to move Character to the Base Position but, how I do that?
Thanks!

How aren’t you able to access it? The object should already be inside of the viewport.

Not even the mouse icon of the ClickDetector shows up. I think there is no way to access a part from a ViewPartFrame by clicking yet.

That is true, I tested it in Studio with ClickDetectors, Buttons on SurfaceGui’s, and buttons on BillboardGui’s. ViewportFrames do not support input from any of its children. This would make sense since these frames are only meant to be used to display parts, not interact with them.

If that is your final conclusion, don’t forget to tag your own reply as the solution!

2 Likes

Oh, so what you’re trying to do is click the part thats inside of a ViewPortFrame using a ClickDetector object?

On the dev wiki, it states the following:

  • The viewport will only update when its children (camera or objects within) are changed.

So, I think I would be right in saying that the frame couldn’t update the click detector to achieve what you’re saying.

1 Like