Luduvo Contents
Theme
On this page

Session

tracks the players on this server, the character each one drives, and the signals that fire as they join, leave, and die

Properties

3 members Access: read only

CharacterDied: Signal

fires with the character, the user id, and the attacker

PlayerJoined: Signal

fires when a player joins

PlayerLeft: Signal

fires when a player leaves

Methods

4 members

BindCharacter(userId: number, character: Instance) -> () [server]

bind a character entity to a user

Parameters
NameTypeDescription
userIdnumberPlayer user ID to associate.
characterInstanceCharacter entity to bind to the player.
returns()—
CharacterOf(userId: number) -> Instance?

the character bound to a user

Parameters
NameTypeDescription
userIdnumberPlayer user ID whose character to look up.
returnsInstance?—
Kick(userId: number, reason: string?) -> boolean [server]

remove a player from this server

Parameters
NameTypeDescription
userIdnumberPlayer user ID to disconnect.
reasonstring?Optional explanation displayed to the disconnected player.
returnsboolean—
LocalCharacter() -> Instance?

the character entity of the local client

Managing Player Connections and Avatars

Lifecycle: Server

Joins and leaves are the two hooks a character spawn cycle hangs off.

Luau
local function spawnCharacter(userId: number)	local character = game.Prefabs.Spawn("Cadet")	if character then		character.Position = Vector3.new(0, 5, 0)		game.Session.BindCharacter(userId, character)	endendgame.Session.PlayerJoined:Connect(function(userId: number)	print("Player joined:", userId)	spawnCharacter(userId)end)game.Session.PlayerLeft:Connect(function(character, userId: number)	print("Player left:", userId)	if character then		character:Destroy()	endend)