Summer 2026 Music Kit Competition is now here! - Create a summer themed electronic music kit and submit it by - Enter Now!
Player entities are returned by Instance.GetPlayerController, Instance.GetAllPlayerControllers, and the player events. A player is an ordinary Entity, so all Entity Methods work on it too. The functions below are player-only and throw a TypeError when called on a non-player Entity.
| Function | Returns | Description |
|---|---|---|
player.GetPlayerSlot() |
number | Zero-based player slot. |
player.GetPlayerName() |
string | Player name. |
player.GetSteamID() |
string | Steam2 network ID, for example STEAM_0:1:504269. |
player.GetSteamID64() |
string | Authenticated 64-bit Steam ID. Returned as a string to avoid JavaScript integer precision loss. Returns "" when unavailable. |
player.IsBot() |
boolean | Whether this is a fake client. |
player.IsConnected() |
boolean | Connection state. |
player.IsObserving() |
boolean | Whether the player is an observer. |
player.GetPlayerPawn() |
Entity | Returns the same Entity; Garry's Mod has no controller/pawn split. |
player.GetPlayerController() |
Entity | Returns the same Entity. |
| Function | Returns | Description |
|---|---|---|
player.GetScore() |
number | Frag count. |
player.GetArmor() |
number | Armor value. |
player.JoinTeam(team) |
undefined | Changes to the supplied integer team number. |
player.PrintMessage(destination, message) |
undefined | Sends this player a message using one of the HUD destinations. Messages are limited to 255 bytes. |
| Function | Returns | Description |
|---|---|---|
player.GiveNamedItem(name) |
Entity or undefined | Gives a named item and returns the created entity when available. The name is limited to 128 bytes. |
player.GiveWeapon(weaponClass) |
WeaponEntity or undefined | Alias of GiveNamedItem for weapon class names. |
player.HasWeapon(weaponClass) |
boolean | Whether the player owns a weapon with the supplied class name. |
player.StripWeapon(weaponClass) |
undefined | Removes the matching weapon from the player's inventory. |
player.SelectWeapon(weaponClass) |
undefined | Selects an owned weapon by class name. |
import { Instance } from "lambda_script/point_script";
Instance.OnScriptInput("EquipKnifeRound", () => {
for (const player of Instance.GetAllPlayerControllers()) {
player.StripWeapon("weapon_ak47");
if (!player.HasWeapon("weapon_knife")) {
player.GiveWeapon("weapon_knife");
}
player.SelectWeapon("weapon_knife");
}
});
These functions query the player's server-side button and movement state. The inputs parameter takes Input flags, combined with | to match any of several inputs.
| Function | Returns | Description |
|---|---|---|
player.IsInputPressed(inputs) |
boolean | Whether any requested Input flag is held in the player's latest server button state. |
player.WasInputJustPressed(inputs) |
boolean | Whether any requested Input flag changed from released to pressed during the current tick. |
player.WasInputJustReleased(inputs) |
boolean | Whether any requested Input flag changed from pressed to released during the current tick. |
player.IsDucking() |
boolean | Whether the player is currently transitioning between the standing and fully ducked hull states. |
player.IsDucked() |
boolean | Whether the player is fully ducked. |
player.IsNoclipping() |
boolean | Whether the player's Source move type is MOVETYPE_NOCLIP. |
import { Input, Instance } from "lambda_script/point_script";
const player = Instance.GetPlayerController(0);
if (player?.WasInputJustPressed(Input.JUMP)) {
Instance.Msg("jump pressed");
}
if (player?.IsInputPressed(Input.ATTACK | Input.ATTACK2)) {
Instance.Msg("a fire input is held");
}
A server or gamemode may add extra player methods, for example player.SetHasHelmet(true). These are server-specific; see project-specific extensions. Calling a player-only extension on a non-player throws TypeError.