API
General notices:
- Functions with
Async
in their name will yield. - The lowercase
player
type is equal toPlayer | int64
. This means it can be a player instance or its UserId. {Value}
stands for{[number]:Value}
, so an array that contains one or multiple ofValue
.- Parameters marked with
?
are optional.
PartyService¶
Properties¶
Parties¶
{[PartyId]:Party} Parties
Queues¶
{[Name]:Queue} Queues
Settings¶
Settings that determine how PartyService operates.
DefaultRank¶
string DefaultRank
RanksAddedByDefault¶
{string} RanksAddedByDefault
TeleportDataValidTime¶
number TeleportDataValidTime
PlayerLostTime¶
number PlayerLostTime
PollingCooldown¶
number PollingCooldown
nil
, it will be automatically updated in the future according to MemoryStoreService limits.
SplitUpGroups¶
boolean SplitUpGroups
QueueExpiration¶
int64 QueueExpiration
Messaging¶
A module which handles all your MessagingService calls. It includes features like packet switching which allows you to send messages with unlimited size. This module is supposed to become even smarter in the future.
SubscribeAsync¶
void SubscribeAsync(string topic, function callback(any message, number sent) -> ())
Unsubscribe¶
void Unsubscribe(string topic)
Publish¶
void Publish(string topic, any message)
Events¶
PlayerLoaded¶
RBXScriptSignal PlayerLoaded(Player player, any teleportData)
PlayerAdded
in order to prevent errors when doing party-related actions with the player.
PartyAdded¶
RBXScriptSignal PartyAdded(Party party)
PartyRemoving¶
RBXScriptSignal PartyRemoving(Party party)
Methods¶
CreateParty¶
Party CreateParty(player leader, {player} | {[Rank]:{player}} members?)
IsInParty¶
boolean, Party? IsInParty(player player, Party party?)
GetPartyFromPlayer¶
Party, Rank GetPartyFromPlayer(player player)
GetQueue¶
Queue GetQueue(config)
config
contains the following:
{
string Name,
int TeamAmount?,
int TeamSize,
function MatchCallback({Player} players, any teams) -> (),
function GetPriority(Player player) -> (number?)?
}
MatchCallback
function gets invoked with an array of the players that are in this server and a table with the team composition. It could look like this:
{
{2376312, 1238712, 2318918, 9852347}, <- team of four players
{1293812, 21748923, 1263712, 9812371}
}
Classic example:
local queue = PartyService:GetQueue({
Name = "Main",
TeamAmount = 2,
TeamSize = 4,
MatchCallback = function(players, teams)
local teleportOptions = Instance.new("TeleportOptions")
teleportOptions.ShouldReserveServer = true
teleportOptions:SetTeleportData({
Teams = teams
})
local result = PartyService:TeleportAsync(6853732367, players, teleportOptions)
print("Teleporting",players,"to reserved server with Id",result.PrivateServerId)
end,
GetPriority = function(player)
return player:GetAttribute("Priority")
end
})
IsInQueueAsync¶
boolean, string? IsInQueueAsync(player player, string queueName?)
TeleportAsync¶
TeleportAsyncResult TeleportAsync(int64 placeId, Player | Party | {Player | Party} players, TeleportOptions teleportOptions?)
TeleportService:TeleportAsync
which manages TeleportData. It ensures that parties persist after teleports. Please pass parties and not the players of the party in order to make it to work. This also sets Party.Teleporting to true
. If you send TeleportData, it must be a table without any number keys.
Party¶
Properties¶
ClassName¶
string ClassName
Created¶
int Created
Leader¶
int64 Leader
Members¶
{int64} Members
PartyService.Settings.RanksAddedByDefault
, more ranks like this will exist in the party.
PartyId¶
int PartyId
Methods¶
AddPlayer¶
void AddPlayer(player player, string rank?)
RemovePlayer¶
void RemovePlayer(player player)
AddRank¶
void AddRank(string rankName, {player} players?)
Party.Rank = {}
. This function should rather be used when you want to add players to it at the same time.
RemoveRank¶
void RemoveRank(string rankName)
PartyService.Settings.DefaultRank
.
ChangePlayerRank¶
void ChangePlayerRank(player player, string newRank)
GetPlayers¶
{player} GetPlayers(string returnType?)
returnType
is "UserId"
. By default, it will return player instances.
GetPlayersWithRank¶
{Player} GetPlayersWithRank(string rank)
GetRankOfPlayer¶
string GetRankOfPlayer(player player)
Destroy¶
void Destroy()
Queue¶
The queue in Roblox's backend is designed like this:
The first two numbers of the key are the priority, the other 4 are the number of entity in this priority
["010001"] = 37292193
^ ^ number of entity in the priority
priority (this isn't the same priority you provide)
{
["550001"] = 24762332
["550002"] = 1387132614
["990001"] = {321761, 213871, 213817127} <- group of 3 players
["990002"] = 935144631 <- this would be the 2nd entity in the priority and 6th player in the queue
["990003"] = 12376612
}
["410784"] = 59826321
-> priority 41, entity number 784 in priority, player with UserId 59826321
Properties¶
ClassName¶
string ClassName
Config¶
{[string]:any} Config
Events¶
PlayerAdded¶
RBXScriptSignal PlayerAdded({Player} players)
PlayerRemoved¶
RBXScriptSignal PlayerRemoved({Player} players)
Methods¶
AddAsync¶
void AddAsync(Player | {Player | {Player}} players)
players
can be a single player or an array containing players and groups.
RemoveAsync¶
void RemoveAsync(player | {player} players)
Destroy¶
void Destroy(boolean wipeQueue?)
true
will yield the function and clear the queue in Roblox's backend.