Players

GetPlayers([onlyEnemies])

Returns a table containing the integer indices of all currently cached players.

Parameters:

  • onlyEnemies: boolean (optional) - If true, only returns indices of players who are on an enemy team. Defaults to false.

-- Get all players
local all_players = entity.GetPlayers()
-- Get only enemies
local enemy_players = entity.GetPlayers(true)

print("Total players:", #all_players)
print("Total enemies:", #enemy_players)

GetLocalPlayer()

Returns the index of the local player.


.Name

Returns: string - The player's username.


.DisplayName

Returns: string - The player's display name.


.UserId

Returns: number - The player's unique UserID.


.Team

Returns: string - The name of the player's team.


.Weapon

Returns: string - The name of the weapon the player is currently holding.


.Position

The 3D world position of the player's position. (Vector3 Object)


.Velocity

The current velocity of the player as a Vector3.


.Health

Returns: number - The player's current health.


.MaxHealth

Returns: number - The player's maximum health.


.IsAlive

Returns: boolean - true if the player's health is greater than 0.


.IsEnemy

Returns: boolean - true if the player is on an opposing team.


.IsVisible

Returns: boolean - true if the player is visible (not occluded by walls).


.IsWhitelisted

Returns: boolean - true if the player is on the global player whitelist.


.BoundingBox

A table with .x, .y, .w, .h fields for the 2D screen-space bounding box.

  • x: number, y: number - The top-left corner of the box.

  • w: number, h: number - The width and height of the box.


.TeamColor

The Color3 object representing the player's team color.


:GetBonePosition(string: boneName)

Returns the 3D world position of a specific bone as a Vector3 object. boneName is a string (e.g., "Head", "HumanoidRootPart").


:GetBoneInstance(string: boneName)

Returns the actual Part Instance of a specific bone, which you can then manipulate with the game API.


:GetBoneSize(boneName)

Returns the size of a specific bone.

  • Parameters:

    • boneName: string - The name of the bone.

  • Returns:

    • Vector3 - The size of the bone, or nil if not found.


:GetBoneRotation(boneName)

Returns the rotation of a specific bone as a 3x3 matrix.

  • Parameters:

    • boneName: string - The name of the bone.

  • Returns:

    • table - An array-like table with 9 number elements representing the rotation matrix, or nil if not found.


Example for Bone Methods

local localplayer = entity.GetLocalPlayer()
if not localplayer then return end

local head_instance = localplayer:GetBoneInstance("Head")
local head_pos = localplayer:GetBonePosition("Head")
local head_size = localplayer:GetBoneSize("Head")

if head_instance then
    local corners = draw.GetPartCorners(head_instance)
    -- you can now draw the corners, refer to the drawing API to see how 
    -- to go from here
end

if head_pos and head_size then
    print("Head is at " .. head_pos.x .. " and is " .. head_size.y .. " studs tall.")
end

Last updated