Garry's Mod Wiki

Player:GetViewEntity

  Entity Player:GetViewEntity()

Description

Returns the entity the player is using to see from (such as the player itself, the camera, or another entity).

This function will not return the currently spectated entity. See Player:GetObserverTarget.

Returns

1 Entity
The entity the player is using to see from

Example

Will print what entity the first player uses to look through.

Output: Player [1][ExamplePlayer]