Tutorial
This section introduces basic functions of the module.
Firstly, get the module here and insert it into your game (preferably ServerStorage).
PartyService only works on the server. Create a script and require it:
local PartyService = require(game.ServerStorage.PartyService)
After that, we'll listen to players joining the game. PartyService.PlayerLoaded
fires when a player was loaded after entering the server.
PartyService.PlayerLoaded:Connect(function(player)
end)
If the player isn't in a party already, we will create one with them being the leader.
PartyService.PlayerLoaded:Connect(function(player)
local party = PartyService:GetPartyFromPlayer(player)
if not party then
party = PartyService:CreateParty(player)
end
end)
Now let's create a matchmaking queue. This is a 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
})
After pasting the code before the PlayerLoaded
event, we can now add the player to the queue.
local queue = ...
PartyService.PlayerLoaded:Connect(function(player)
queue:AddAsync(player)
end)
PartyService.Messaging
is a module which handles all your MessagingService calls. It includes features like packet switching which allows you to send messages with unlimited size.
local messaging = PartyService.Messaging
messaging:SubscribeAsync("Test", function(data, sent)
print(data, sent)
end)
messaging:Publish("Test", "Test message")
messaging:Publish("Test", string.rep("a", 10238)) --this is 10kB large
task.wait(1)
messaging:Unsubscribe("Test")
Info
Here is an example of what you could create with PartyService.