Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How I get the Part Position by clicking on a part inside ViewPortFrames?

Asked by 5 years ago
Edited 5 years ago

Hello! I don't have much experience with viewportframes.. anyway. 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?

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!

Answer this question