GD Resources logo

Player Control #

OmgRod avatar
Written by:
OmgRod
Owner

The 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 #

  1. playerType (integer, optional): An integer enum specifying which player character to destroy. Defaults to 1 (Player.Player1).

Player Enums #

The Player table includes pre-defined integer constants for targeting specific player instances in dual-player scenarios:

Player Type Enums
KeyTypeValueDescription
Player.Player1integer1Targets primary player (Player 1).
Player.Player2integer2Targets secondary player (Player 2) in Dual Mode.
Player.Bothinteger3Targets both players simultaneously.

Basic Usage #

Instant Death #

To immediately destroy Player 1 (the default action):

lua
1-- Kills Player 1
2Player.kill()
3
4-- Explicitly passing the enum
5Player.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 2
2Player.kill(Player.Player2)
3
4-- Destroy both Player 1 and Player 2 simultaneously
5Player.kill(Player.Both)