Creating a Part at Corners of the Screen

As the title says I am trying to make parts at the corners of the screen, but I’m not sure how to. After searching all of DevForum, I’ve only been able to find this post, and tried using it, but it did not work as the part is placed out of frame and pretty much exactly where the Camera is? I’d appreciate any advice or help on how to place parts at the corners of the screen :grin:

Current Code:

local Camera = workspace.CurrentCamera
local viewportSize = Camera.ViewportSize

function getWorldPoint(x,y)
	local ray = Camera:ScreenPointToRay(x, y)
	local worldPosition = ray.Origin + ray.Direction * 1

	return worldPosition
end


local worldPos = getWorldPoint(1,1)--should return top left
local worldPos = getWorldPoint(viewportSize.X,1) -- should return top right

this code is ran on the client btw

1 Like