Skip to content

AvatarAPI

Accessible via the AvatarAPI Global. This API provides access to the Local Avatar

There are some events for avatars, they can be checked here: Avatar Events

NameDescription
LocalAvatar : Avatar
(Returns Avatar)
Access the Local Player’s Avatar instance reference
CurrentAvatar : Avatar
(Returns Avatar)
Access the Script’s Avatar instance reference (the avatar the script is running on). This is only available on avatar scripts

The Avatar instances can be accessed via:

  • The AvatarAPI.LocalAvatar Global
  • The player instance (Player). It has a property named Avatar
PropertyDescription
AvatarID : stringUnique identifier for the avatar. Retrieves the avatar’s asset object ID.
Wearer : Player
(Returns Player)
Reference to the avatar’s wearer Player’s Player
IsLoaded : boolReturns whether an avatar is loaded or not.
IsHuman : boolChecks if the animator’s avatar is humanoid.
MethodDescription
GetHeight() : floatReturns the height of the avatar.
Returns the viewpoint height if the avatar is not loaded.
GetInitialHeight() : floatReturns the initial height of the avatar.
Defaults to 1.6m if no avatar is loaded.
MethodDescription
HasBone(HumanBodyBones humanBone) : boolChecks if the specified human body bone is present in the avatar.
GetBonePosition(HumanBodyBones humanBone) : Vector3Gets the world position (Vector3) of a specified bone. Returns nil if missing.
GetBoneRotation(HumanBodyBones humanBone) : QuaternionGets the world rotation (Quaternion) of a specified bone. Returns nil if missing.
GetBonePositionAndRotation(HumanBodyBones humanBone) : Vector3, QuaternionGets the world position and rotation (Tuple(Vector3, Quaternion)) of a specified bone. Returns nil if missing.
MethodDescription
HasParameter(string parameterName) : boolChecks if the specified parameter exists in the avatar’s animator.
GetParameterAsBool(string parameterName) : boolRetrieves a boolean parameter from the animator. Returns nil if the parameter does not exist.
GetParameterAsInt(string parameterName) : intRetrieves an integer parameter from the animator. Returns nil if the parameter does not exist.
GetParameterAsFloat(string parameterName) : floatRetrieves a float parameter from the animator. Returns nil if the parameter does not exist.
SetParameter(string parameterName, bool/float/int parameterValue) : voidSets an animator parameter to a set value.
Internally will cast to the type actually used by the Animator.

Requesting the picture is a bit more complicated as it needs to be acquired in the first place. So it’s not a function that will give the results right away. Instead, it uses a callback lua function, which is basically a normal lua function that gets called whenever the request is finished.

For a complete example, check: Player Profile and Avatar Picture Example

NameDescription
RequestImage(callback OnAvatarImage, bool castToTexture) : void
  - #arg1 lua function for the callback
  - #arg2 [Optional] Whether to cast the Texture2D to Texture or not.
Sends a request to fetch the Player Avatar’s picture as a Texture2D or as a Texture.
NameDescription
OnAvatarImage(Texture2D/Texture texture, string avatarID) : void
  - #arg1 The Texture/Texture2D reference for the avatar’s image
  - #arg2 [Optional] The Avatar’s ID the image belongs to
Gets called when RequestImage finished and is sending the results