Players.Kill

Declaration

Players.Kill(number PlayerID)

Description

Kills the player with the specified PlayerID.

--Kills the first player
local allPlayers = Players.GetAll();
Players.Kill(allPlayers[1]);

Declaration

Players.Kill(number PlayerID, TargetPlayer Mode, Vector3 Origin)

Description

Kills the specified player(s), depending on the Mode. If using Mode set to Closest or Furthest, the Origin parameter will be used as the point of reference, otherwise Vector3.zero can be passed.

Check TargetPlayer for all possible Mode values.

--Kills everyone but the player with ID 2
local DontKill = 2;
local Mode = TargetPlayer.Others;
Players.Kill(DontKill, Mode, Vector3.zero);

--Kills the third player
local allPlayers = Players.GetAll();
Players.Kill(allPlayers[3]);

--Kills everyone on the same team as the passed player
Players.Kill(1, TargetPlayer.AllTeamMembers, Vector3.zero);

--Kills random player, the PlayerID parameter is not used
Players.Kill(0, TargetPlayer.Random, Vector3.zero);

--Kills the closest player to the middle of the map, PlayerID is once more not used
local world = World.GetSettings();
Players.Kill(0, TargetPlayer.Closest, V3(world.Width / 2, 1, world.Height / 2));

Declaration

Players.Kill(Dictionary<number> PlayerIDs)

Description

Kills the specified players.

--Retrieves every single player and kills them
local allPlayers = Players.GetAll();
Players.Kill(allPlayers);

--Kills the second and fourth players
Players.Kill({allPlayers[2], allPlayers[4]});

Note

Player IDs must be whole numbers.

Keep in mind the Player IDs aren't necessarily ordered. Players can join and leave in the lobby, potentially several times, increasing their ID, which is why using Players.GetAll is advised if you want to target a player at a specific slot.

You can also pass Player objects instead of numbers as IDs.