Scale problems with ViewportFrames and WorldToViewportPoint


I’ve been struggling to use WorldToViewportPoint in my viewportframes, and from what I’ve observed the positions are being messed up when the frame is scaled beyond a 1:1 aspect ratio. Why is this happening? How can I fix this?

Code:

button.Parent = vpf
button:SetAttribute("Type",v.Name)

local function render()
	local campos,depth = vpfcam:WorldToViewportPoint(v.Position)
			
	button.Visible = depth

	button.Position = UDim2.fromScale(campos.X,campos.Y)
			
	print(button.Position)
end

rns.RenderStepped:Connect(render)
1 Like

Seems like you’d need to either multiply or divide the points by whatever the aspect ratio of the frame is.