Player Control #
Written by:
OmgRod
OwnerThe Player API allows you to directly interact with and control the player characters during gameplay.
API Reference #
Player.kill([playerType]) #
Destroys the specified player instance, triggering the death/respawn sequence for the current layer.
Arguments #
playerType(integer, optional): An integer enum specifying which player character to destroy. Defaults to1(Player.Player1).
Player Enums #
The Player table includes pre-defined integer constants for targeting specific player instances in dual-player scenarios:
| Key | Type | Value | Description |
|---|---|---|---|
Player.Player1 | integer | 1 | Targets primary player (Player 1). |
Player.Player2 | integer | 2 | Targets secondary player (Player 2) in Dual Mode. |
Player.Both | integer | 3 | Targets both players simultaneously. |
Basic Usage #
Instant Death #
To immediately destroy Player 1 (the default action):
lua
1-- Kills Player 12Player.kill()34-- Explicitly passing the enum5Player.kill(Player.Player1)
Dual Mode Targeting #
When working in Dual Mode, you can target specific players or destroy both at once:
lua
1-- Destroy only Player 22Player.kill(Player.Player2)34-- Destroy both Player 1 and Player 2 simultaneously5Player.kill(Player.Both)
