Character
A player’s body in the world.
- Inherits: Instance
- Creatable: No. The server creates one each time a player spawns (or
loadCharacter()is called). - Replication: Replicated: clients get a copy, and changes the server makes reach them.
The server creates a character each time a player spawns, names it after the player and puts it in the Workspace. Its body is a capsule 5 studs tall with a radius of 1.
Each player moves their own character on their device, so movement feels instant, and sends its
position 20 times a second. The server checks every move against walkSpeed and jumpPower and
snaps the character back when a move goes too far. Physics doesn’t push characters: balls and
explosions don’t knock them back.
Scripts on the server change a character through its properties: walkSpeed, jumpPower,
health, teleport(). A character dies when health reaches 0 or it falls below
workspace.fallenPartsDestroyHeight; it respawns after Players.respawnTime unless
Players.characterAutoLoads is off.
Properties
Section titled “Properties”position
Section titled “position”Type: Vector3 · Default: new Vector3(0, 0, 0) · Access: read/write · Replicates: yes
Center of the body. Assigning it teleports the character.
The player’s device moves the character; the server’s value follows it. That device doesn’t
receive position, rotation, velocity or state from the server: it is their source.
rotation
Section titled “rotation”Type: Vector3 · Default: new Vector3(0, 0, 0) · Access: read/write · Replicates: yes
Facing, in degrees (y is the turn).
velocity
Section titled “velocity”Type: Vector3 · Default: new Vector3(0, 0, 0) · Access: read-only · Replicates: yes
Velocity in studs per second, as the player’s device reports it.
Type: CharacterState · Default: 'idle' · Access: read-only · Replicates: yes
What the character is doing, as the player’s device reports it. It becomes 'dead' when health
reaches 0.
walkSpeed
Section titled “walkSpeed”Type: number · Default: 16 · Range: 0 to 200 (clamped) · Access: read/write · Replicates: yes
Studs per second.
New characters take it from StarterPlayer.characterWalkSpeed.
jumpPower
Section titled “jumpPower”Type: number · Default: 50 · Range: 0 to 400 (clamped) · Access: read/write · Replicates: yes
Upward speed when jumping.
With the default gravity, 50 jumps about 6 studs high. New characters take it from
StarterPlayer.characterJumpPower.
health
Section titled “health”Type: number · Default: 100 · Range: 0 or more (clamped) · Access: read/write · Replicates: yes
Current health. When it reaches 0 the character dies: state becomes 'dead' and died fires.
Nothing caps it at maxHealth.
maxHealth
Section titled “maxHealth”Type: number · Default: 100 · Range: 1 or more (clamped) · Access: read/write · Replicates: yes
Full health. New characters start with health equal to it, from
StarterPlayer.characterMaxHealth; the
health bar over a character’s head shows health against it.
Type: Color3 · Default: Color3.fromHex('#2c7afd') · Access: read/write · Replicates: yes
Body color.
New characters take their player’s teamColor.
player
Section titled “player”Type: Player | null · Default: null · Access: read-only · Replicates: yes
The Player this character belongs to.
Character.radius
Section titled “Character.radius”Static · Type: number · Access: read-only · Value: 1
Radius of the body’s capsule, in studs.
Character.height
Section titled “Character.height”Static · Type: number · Access: read-only · Value: 5
Total height of the body’s capsule, in studs.
Inherited from Instance: name, archivable, id, className, parent, destroyed
Methods
Section titled “Methods”teleport
Section titled “teleport”teleport(position: Vector3): voidMoves the character to position instantly (assigning position does the same). On the server,
the player’s device is told to move it there too. Its velocity resets to zero.
takeDamage
Section titled “takeDamage”takeDamage(amount: number): voidLowers health by amount, not below 0. Does nothing if the character is already dead or
amount isn’t a positive number.
kill(): voidSets health to 0.
Inherited from Instance: getPropertyChangedSignal, setAttribute, getAttribute, getAttributes, getAttributeChangedSignal, getChildren, getDescendants, findFirstChild, findFirstChildOfClass, findFirstChildWhichIsA, findFirstAncestor, findFirstAncestorWhichIsA, waitForChild, isA, isDescendantOf, isAncestorOf, getFullName, clearAllChildren, destroy, clone, toString
Events
Section titled “Events”Arguments: none
Fires once, when health drops to 0.
Inherited from Instance: changed, childAdded, childRemoved, descendantAdded, descendantRemoving, ancestryChanged, destroying, attributeChanged
Examples
Section titled “Examples”Damage, heal and teleport
Section titled “Damage, heal and teleport”import { Character, Part, Vector3, getChild, workspace } from '@rally/sdk';
const spikes = getChild(workspace, 'Spikes', Part);spikes.touched.connect((other) => { if (other instanceof Character) other.takeDamage(25);});
const pad = getChild(workspace, 'HealPad', Part);pad.touched.connect((other) => { if (other instanceof Character) other.health = other.maxHealth;});
const portal = getChild(workspace, 'Portal', Part);portal.touched.connect((other) => { if (other instanceof Character) other.teleport(new Vector3(0, 50, 0));});