hello, i’m trying to get the position of some parts to convert them into 2d positions and that it take the place of the screws of my ventilation hatch or whatever it is called
this is with the current camera
and when i make it with the viewport frame the gui’s appears in top left of the screen
how can i put the gui’s in the screws with the viewportframe camera?
local vpfcamera = Instance.new("Camera", viewportframe)
vpfcamera.CFrame = campart.CFrame * CFrame.new(0,-.45,0)
vpfcamera.Name = "vpfcamera"
viewportframe.CurrentCamera = vpfcamera
for _, tornillos in pairs(worldmodel:GetChildren()) do
if tornillos.Name == "Screw" then
local wpoint = tornillos.Position
local screenpos, onscreen = vpfcamera:WorldToViewportPoint(wpoint)
if not onscreen then
return
end
local button = Instance.new("ImageButton", viewportframe.Parent)
button.Name = "ScrewGUI"
button.Visible = true
button.AnchorPoint = Vector2.new(.5,.5)
button.Size = UDim2.new(0,32,0,32)
button.Position = UDim2.new(0,screenpos.X, 0, screenpos.Y)