Skip to main content

Players

This is a MapLib Feature. It can be accessed by MapLib:GetFeature("Players").

Functions

GetPlayers

Players:GetPlayers() → {Player?}

This function can be used to get all players in the current round.

Example:

--Teleports all players ingame to map.Destination.
local PlayersFeature = MapLib:GetFeature("Players")
local TeleportFeature = MapLib:GetFeature("Teleport")

for _, player in pairs(PlayersFeature:GetPlayers()) do
	TeleportFeature:Teleport(player, map.Destination.Position)
end

GetPlayersInRadius

since 0.11
</>
Players:GetPlayersInRadius(
positionVector3,
radiusnumber
) → {Player?}

This function can be used to get all the players which are in a radius from a position.

Example:

--Teleports all players that are within 5 studs from map.Spawn.
local PlayersFeature = MapLib:GetFeature("Players")
local TeleportFeature = MapLib:GetFeature("Teleport")

for _, player in pairs(PlayersFeature:GetPlayersInRadius(map.Spawn.Position, 5)) do
	TeleportFeature:Teleport(player, map.Destination.Position)
end
Show raw api
{
    "functions": [
        {
            "name": "GetPlayers",
            "desc": "This function can be used to get all players in the current round.\n\n**Example:**\n```lua\n--Teleports all players ingame to map.Destination.\nlocal PlayersFeature = MapLib:GetFeature(\"Players\")\nlocal TeleportFeature = MapLib:GetFeature(\"Teleport\")\n\nfor _, player in pairs(PlayersFeature:GetPlayers()) do\n\tTeleportFeature:Teleport(player, map.Destination.Position)\nend\n```\t",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{Player?}"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 36,
                "path": "src/Features/Players.lua"
            }
        },
        {
            "name": "GetPlayersInRadius",
            "desc": "This function can be used to get all the players which are in a radius from a position.\n\n**Example:**\n```lua\n--Teleports all players that are within 5 studs from map.Spawn.\nlocal PlayersFeature = MapLib:GetFeature(\"Players\")\nlocal TeleportFeature = MapLib:GetFeature(\"Teleport\")\n\nfor _, player in pairs(PlayersFeature:GetPlayersInRadius(map.Spawn.Position, 5)) do\n\tTeleportFeature:Teleport(player, map.Destination.Position)\nend\n```\t",
            "params": [
                {
                    "name": "position",
                    "desc": "",
                    "lua_type": "Vector3"
                },
                {
                    "name": "radius",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{Player?}"
                }
            ],
            "function_type": "method",
            "since": "0.11",
            "source": {
                "line": 62,
                "path": "src/Features/Players.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "Players",
    "desc": "This is a MapLib Feature. It can be accessed by `MapLib:GetFeature(\"Players\")`.",
    "source": {
        "line": 17,
        "path": "src/Features/Players.lua"
    }
}