Skip to content

Players

Not to be confused with Player, the object that represents a single player.

Service Object

This object is automatically created by Polytoria. Additionally, scripts cannot change its parent.

Not newable

This object cannot be created by scripts using Instance.New().

Players is the container class for all Player instances.

Inherits Instance

Events

PlayerAdded

Parameters: player [ Player ]

Fires when a player joins the server.

Example

game["Players"].PlayerAdded:Connect(function(player)
    if player.Name == "Player" then
        player:Kick("A player has joined the server, so they have been removed.")
    end
end)

PlayerRemoved

Parameters: player [ Player ]

Fires when a player leaves the server.

Example

game["Players"].PlayerRemoved:Connect(function(player)
    if player.Name == "Player" then
        print("A player has left the server.")
    end
end)

Methods

GetPlayer → Player

Parameters: username [ String ]

Returns the player instance from their username.

GetPlayerByID → Player

Parameters: userID [ int ]

Returns the player instance from their user ID.

GetPlayers → []

Returns all players in the place as a table.

Example

for i, player in ipairs(game["Players"]:GetPlayers()) do
    print(player.Name .." is in the server!")
end

Properties

LocalPlayer : Player

Returns the local player currently playing.

This property is read-only and cannot be modified.

This is only available to the client. It can only be accessed within local scripts.

Example

print(game["Players"].LocalPlayer.Name)

PlayerCollisionEnabled : boolean

Determines whether or not collisions between players are enabled.

Example

print("Turning off player collisions!")
game["Players"].PlayerCollisionEnabled = false