function ScreenSpace.ScreenToWorldByWidth(p,n,T,y)local x=ScreenSpace.AspectRatio()local V=math.tan(math.rad(workspace.CurrentCamera.FieldOfView)/2)local b=x*V local F,B=ScreenSpace.ViewSizeX(),ScreenSpace.ViewSizeY()local M=-(F*y)/((T*2)*b)local I,G=(p/F)*2-1,(n/B)*2-1 local Q=(I*-b)*M local c=(G*V)*M return Vector3.new(Q,c,M)end return ScreenSpace

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



