Yuari
Documentation
Docs/Core functions/worldtoscreen

worldtoscreen

Projects a Vector3 through the current camera and reports whether it is visible.

Syntax

worldtoscreen(position: Vector3) -> Vector2, boolean
WorldToScreen(position: Vector3) -> Vector2, boolean

Parameters

ParameterTypeDescription
positionVector3World-space point to project.

Returns

TypeDescription
Vector2Screen position in client-space pixels.
booleanTrue when the point is in front of the camera and inside the viewport.

Description

The function reads the current camera from Workspace and projects the point using the same path as Camera:WorldToViewportPoint.

When there is no camera, or projection fails, it returns Vector2(0, 0), false.

Example

local screen, onScreen = worldtoscreen(Vector3.new(0, 10, 0))
if onScreen then
    print(screen.X, screen.Y)
end

Notes

  • WorldToScreen is an alias of worldtoscreen.
  • The boolean is false for off-screen points, not only points behind the camera.
  • :WorldToViewportPoint() and :WorldToScreenPoint() remain available on instances.