function ScreenSpace.ScreenToWorldByWidth(n,u,t,C)local U=ScreenSpace.AspectRatio()local K=math.tan(math.rad(Workspace.CurrentCamera.FieldOfView)/2)local Q=U*K local Z,o=ScreenSpace.ViewSizeX(),ScreenSpace.ViewSizeY()local d=-(Z*C)/((t*2)*Q)local s,A=(n/Z)*2-1,(u/o)*2-1 local j=(s*-Q)*d local L=(A*K)*d return Vector3.new(j,L,d)end return ScreenSpace
-- ScreenSpace -> WorldSpace. Taking a screen width that you want that object to be
-- and a world width that is the size of that object, and returning the position to
-- put that object at to satisfy those.
function ScreenSpace.ScreenToWorldByWidth(x, y, screenWidth, worldWidth)
	local aspectRatio = ScreenSpace.AspectRatio()
	local hfactor = math.tan(math.rad(Workspace.CurrentCamera.FieldOfView) / 2)
	local wfactor = aspectRatio * hfactor
	local sx, sy = ScreenSpace.ViewSizeX(), ScreenSpace.ViewSizeY()
	--
	local depth = -(sx * worldWidth) / (screenWidth * 2 * wfactor)
	--
	local xf, yf = x / sx * 2 - 1, y / sy * 2 - 1
	local xpos = xf * -wfactor * depth
	local ypos = yf * hfactor * depth
	--
	return Vector3.new(xpos, ypos, depth)
end

return ScreenSpace
