Skip to main content

sm.localPlayer

Local player represents the current character being controlled on the client's computer.
This library can only be used on the client.

For more information about other players in the world, see sm.player.

Functions

addRenderable

sm.localPlayer.addRenderable( file )
Client-Only

Adds a renderable (file containing model data) to be used for the local player in first person view.

Arguments:
  • file [ string ]: The path to the renderable file.

getActiveItem

sm.localPlayer.getActiveItem()
Client-Only

Returns the item currently held by the local player.

Returns:
  • [ Uuid ]: The uuid of the held item.

getAimSensitivity

sm.localPlayer.getAimSensitivity()
Client-Only

Returns the local player's aim sensitivity.

Returns:
  • [ number ]: The aim sensitivity.

getCarry

sm.localPlayer.getCarry()
Client-Only

Returns the local player's carrying container.

Returns:

getCarryColor

sm.localPlayer.getCarryColor()
Client-Only

Returns the color of the shape that the local player is carrying.

Returns:
  • [ Color ]: The player's carry color.

getDirection

sm.localPlayer.getDirection()
Client-Only

Returns the direction in which the local player is looking.

Returns:
  • [ Vec3 ]: The player's aim direction.

getFpAnimationInfo

sm.localPlayer.getFpAnimationInfo( name )
Client-Only

Returns general information for a first person view animation.

Arguments:
  • name [ string ]: The animation name.
Returns:
  • [ table ]: A table containing name, duration and looping information of the animation.

getFpBonePos

sm.localPlayer.getFpBonePos( name )
Client-Only

Returns the world position for a bone in the first person view animation skeleton.

Arguments:
  • name [ string ]: The bone name.
Returns:
  • [ Vec3 ]: The bone position.

getHotbar

sm.localPlayer.getHotbar()
Client-Only

Returns the local player's hotbar container.

Returns:

getId

sm.localPlayer.getId()
Client-Only

Returns the local player's id.

Returns:
  • [ int ]: The id.

getInventory

sm.localPlayer.getInventory()
Client-Only

Returns the local player's inventory container.

Returns:

getMouseDelta

sm.localPlayer.getMouseDelta()
Client-Only

Returns the delta position of the mouse.

Returns:
  • [ number ]: Mouse Delta X.
  • [ number ]: Mouse Delta Y.

getOwnedLift

sm.localPlayer.getOwnedLift()
Client-Only

Returns the local player's lift.

Returns:

getPlayer

sm.localPlayer.getPlayer()
Client-Only

Returns the local player's player object.

Returns:

getPosition

sm.localPlayer.getPosition()
warning

This function is deprecated.

Use sm.localPlayer.getPlayer().character.worldPosition instead.


getRaycast

sm.localPlayer.getRaycast( range, origin, direction )
Client-Only

Performs a raycast relative to the local player's perspective.

Arguments:
  • range [ number ]: The maximum range.
  • origin [ Vec3 ]: The start position. Defaults to sm.localPlayer.getRaycastStart()
  • direction [ Vec3 ]: The direction. Defaults to sm.localPlayer.getDirection()
Returns:
  • [ bool ]: Whether the raycast was successful or not.
  • [ RaycastResult ]: The raycast result data.

getRaycastStart

sm.localPlayer.getRaycastStart()
Client-Only

Returns the start position of the local player's raycast.
The position depends on the camera's position, and whether it's in first - or third-person.

Returns:
  • [ Vec3 ]: The start position of the raycast.

getRight

sm.localPlayer.getRight()
Client-Only

Returns the right-vector perpendicular to the local player's aim.

Returns:
  • [ Vec3 ]: The right-vector of the local player's aim.

getSelectedHotbarSlot

sm.localPlayer.getSelectedHotbarSlot()
Client-Only

Returns the selected hotbar slot.

Returns:
  • [ int ]: The selected slot.

getUp

sm.localPlayer.getUp()
Client-Only

Returns the up-vector perpendicular to the local player's aim.

Returns:
  • [ Vec3 ]: The up-vector of the local player's aim.

isGarmentUnlocked

sm.localPlayer.isGarmentUnlocked( uuid )
Client-Only

Checks if the garment has been granted to the local player.

Arguments:
  • uuid [ Uuid ]: The garment uuid.
Returns:
  • [ bool ]: Whether the garment is unlocked or not.

isInFirstPersonView

sm.localPlayer.isInFirstPersonView()
Client-Only

Returns whether the player is in first person view where the viewpoint is rendered from the player's perspective.
Otherwise, the player is in third person view where the camera is behind the player.

Returns:
  • [ bool ]: Whether the player is in first-person view or not.

removeRenderable

sm.localPlayer.removeRenderable( renderable )
Client-Only

Removes a renderable (file containing model data) that was used for the local player in first person view.

Arguments:
  • renderable [ string ]: The path to the renderable file.

setBlockSprinting

sm.localPlayer.setBlockSprinting( state )
Client-Only

Stops the local player from sprinting.

Arguments:
  • state [ bool ]: Whether sprinting is blocked or not.

setDirection

sm.localPlayer.setDirection( dir )
Client-Only

Sets the direction of where the player is viewing or aiming.
Intended to be used when the controls have been locked (See sm.localPlayer.setLockedControls).

Arguments:
  • dir [ Vec3 ]: The direction.

setLockedControls

sm.localPlayer.setLockedControls( state )
Client-Only

Locks the player's controls.

A player with locked controls can:

  • Open the game menu by pressing ESC
  • Open the chat

A player with locked controls cannot:

  • Interact with parts
  • Open their inventory
  • Move in any way
  • Look around
  • Change the selected hotbar item
  • Use any tools
  • Place or remove any parts
Arguments:
  • state [ bool ]: The lock state.

updateFpAnimation

sm.localPlayer.updateFpAnimation( name, time, weight, looping )
Client-Only

Updates a first person view animation.

Arguments:
  • name [ string ]: The animation name.
  • time [ number ]: The time.
  • weight [ number ]: The weight. Defaults to -1.0
  • looping [ bool ]: Whether the animation is looping or not. Defaults to false.