OOP Party System V2

Hey everyone! I am super excited to release OOP Party System V2, a reworking of my V1 Party System. This release contains a whole bunch of new improvements and functionality in an attempt to make it easier, stronger, and more flexible for player party managing in your game.
Let me know if you see any missing information, or have anything I could improve upon :slight_smile: I have attempted to test all functions, and test for issues but I cannot test for them all. So let me know if you find any please!

Get the full OOP Party System V2 - Model from this link.

What’s in This Module?

This is a universal player party system based on functions such as leadership, invitations, permission, blacklist, and teleportation. Version 2 is a package of everything in the first, enhanced error management, enhanced event management, and more streamlined functionality.

How it is used

Place the module somewhere in your project, and reference it. Make sure the modules it needs, and the PhysicalParties folder are within it still (Event, Remotes, Utils). Unless you go and change the code manually to place them somewhere else.

local PartySystem = require(ReplicatedStorage.PartySystem)

From there, parties can be made, members managed, and events can be hooked in. Here is a quick example:

-- Create a new party.
local party = PartySystem.new(game.Players.Player1)

-- Invite a player.
party:InvitePlayer(game.Players.Player2)

-- Listen for when someone joins a party.
PartySystem:OnMemberJoined(function(party, member, members)
    print(member.Name .. " joined " .. party.PartyName .. "!")
end)

Major Revisions since Version 1

This version is an improvement on the first, making some substantial improvements.

  • Automatic error handling: Functions now return true on success and false on error with explanatory alerts.

  • Enhanced Event Support: Custom Event module based event system replaces outdated onInviteSent callback. Extend events OnMemberJoined, OnDisband, and OnInviteExpired in a convenient way.

  • Remote Handling Enhancement: The client-server communication is handled by a RemoteHandler module, which includes new methods such as InvitePlayerByUsername and AcceptInvite.

  • Unique IDs for parties: Parties now have a reference ID using GetPartyById.

  • New Functions: Added LeaveParty, InvitePlayerByUsername, SetPartyName, and ClearBlacklist, among lots of others, for improved flexibility.

  • Type Safety: Strict Lua type annotations for enhanced code readability and IntelliSense.

  • Better Member Control: Separates voluntary leaving (LeaveParty) and expulsion (RemoveMember), event-notified through OnMemberLeft.

Key Features

Here’s a summary of all OOP Party System V2 contains:

  • Party Creation and Control: Create parties of a leader, set a maximum number of members automatically set to 4, and automatically disbanded when needed.

  • Invites: Generate and send an invite with a 20-second time-to-reply. Players have a chance of accepting an invite.

  • Permissions: Grant CanKick and CanInvite permission to members (leaders have these automatically).

  • Blacklisting: Blacklisting of players so they cannot join, unblacklisting, and clearing.

  • Teleportation: Teleport your party members somewhere on optional reserved servers.

  • Event system: Events for invitations, member change, disbans, etc.

  • Party Name Assigning: Give your parties individualized personal names.

Feedback or Questions

I’d love to hear your thoughts, suggestions, or bug reports! Feel free to reply here or contact me via Roblox messages.

Automatic Remote Function and Client Methods

OOP Party System V2 automatically creates a RemoteFunction named PartyRemoteFunction in ReplicatedStorage when the module initializes, handled by the Remotes module. This remote function enables seamless client-server communication, allowing clients to invoke server-side party management methods. Here are the methods you can call via PartyRemoteFunction:InvokeServer from the client:

  • CreateParty – Creates a new party for the calling player.

  • InvitePlayer(player: Player) – Invites a specified player to the caller’s party (requires CanInvite permission).

  • AcceptInvite(partyId: string) – Accepts an invite to join a party with the given party ID.

  • LeaveParty – Allows the calling player to leave their current party (if not the leader).

  • KickMember(member: Player) – Kicks a specified member from the caller’s party (requires CanKick permission and leadership).

  • TransferOwnership(newLeader: Player) – Transfers party leadership to a specified member (requires current leadership).

  • ToggleInviteOnly(toggle: boolean) – Sets whether the party is invite-only (requires leadership).

  • SetMaxMembers(maxMembers: number) – Sets the maximum number of party members (requires leadership).

  • DisbandParty – Disbands the caller’s party (requires leadership).

  • SetPermission(member: Player, permission: string, toggle: boolean) – Sets a permission (e.g., β€œCanKick”, β€œCanInvite”) for a member (requires leadership).

  • RevokeInvite(player: Player) – Revokes a pending invite for a specified player (requires CanInvite permission).

  • SetPartyName(name: string) – Changes the party’s name (requires leadership).

  • GetParty(targetPlayer: Player) – Retrieves the party of a specified player; returns success (boolean) and the party object.

These methods return true on success and false on failure, with warnings logged server-side for errors. Clients can use these remotely to interact with the party system.
Feel free to go into the Remotes module and add more to it if you wish or remove it all together.

Here is a brief example of a remote call

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local player = Players.LocalPlayer
local remoteFunction = ReplicatedStorage:WaitForChild("PartyRemoteFunction")

-- Invite another player
remoteFunction:InvokeServer("InvitePlayer", Players:FindFirstChild("Player2"))

Here is the entire documentation, which is also located at the very top of the module.

--[[
    Usage: Place in ReplicatedStorage, e.g., local PartySystem = require(game.ReplicatedStorage.PartySystem.Parties)

    Core Methods:
    - new(leader: Player): Party – Creates party; returns Party object.
    - GetParty(player: Player): Party | nil – Gets player’s party or nil.
    - GetPartyById(partyId: string): Party | nil – Finds party by ID; returns Party or nil.
    - GetAllParties(): {[string]: Party} – Returns all active parties by ID.

    Party Methods:
    - Disband(): bool – Disbands party (leader only); returns true/false.
    - TransferOwnership(member: Player): bool – Transfers leadership; updates perms; returns true/false.
    - InvitePlayer(player: Player): bool – Invites player (needs CanInvite); returns true/false.
    - InvitePlayerByUsername(username: string): bool – Invites by username; returns true/false.
    - AddMember(member: Player): bool – Adds member after invite; checks limits; returns true/false.
    - RemoveMember(member: Player): bool – Kicks member (leader, CanKick); fires OnMemberLeft (kicked=true); returns true/false.
    - LeaveParty(member: Player): bool – Member leaves voluntarily; fires OnMemberLeft (kicked=false); returns true/false.
    - BlacklistPlayer(player: Player): bool – Blacklists player, removes if in party; returns true/false.
    - UnblacklistPlayer(player: Player): bool – Removes from blacklist; returns true/false.
    - SetMaxMembers(maxMembers: number): bool – Sets max party size; returns true.
    - SetPermission(member: Player, perm: string, toggle: bool): bool – Sets "CanKick"/"CanInvite" for member; returns true/false.
    - ToggleInviteOnly(toggle: bool): bool – Sets invite-only status; returns true.
    - GetMembers(): {Player} – Returns member list.
    - IsMember(player: Player): bool – Checks if player is member; returns true/false.
    - IsLeader(player: Player): bool – Checks if player is leader; returns true/false.
    - IsInviteOnly(): bool – Checks if party is invite-only; returns true/false.
    - HasPermission(member: Player, perm: string): bool – Checks "Leader"/"CanKick"/"CanInvite"; returns true/false.
    - TeleportMembers(placeId: number, data?: {code: string?, job: string?, reserve: bool?}): bool – Teleports members; returns true.
    - GetInvites(): {Player} – Returns invited players.
    - AcceptInvite(player: Player): bool – Accepts invite; returns true/false.
    - RevokeInvite(player: Player): bool – Revokes invite (needs CanInvite); returns true/false.
    - SetPartyName(name: string): bool – Sets party name; returns true.
    - GetBlacklist(): {Player} – Returns blacklisted players.
    - ClearBlacklist(): bool – Clears blacklist; returns true/false.

    Events (Server-Side):
    - OnInviteSent(callback: (invite: Instance, leader: Player, invited: Player, party: Party) -> ()) – Fires on invite; params: invite ObjectValue, leader, invited player, party.
    - OnMemberJoined(callback: (party: Party, member: Player, members: {Player}) -> ()) – Fires on join; params: party, member, member list.
    - OnMemberLeft(callback: (party: Party, member: Player, members: {Player}, kicked: bool) -> ()) – Fires on leave/kick; params: party, member, member list, kicked status.
    - OnPartyCreate(callback: (party: Party) -> ()) - Fires on party creation; params: party
    - OnDisband(callback: (party: Party, leader: Player, members: {Player}) -> ()) – Fires on disband; params: party, leader, members.
    - OnInviteRevoked(callback: (party: Party, player: Player) -> ()) – Fires on invite revoke; params: party, player.
    - OnPartyNameChanged(callback: (party: Party, oldName: string, newName: string) -> ()) – Fires on name change; params: party, old name, new name.
    - OnMemberPermissionsChanged(callback: (party: Party, member: Player, perm: string, toggle: bool) -> ()) – Fires on perm change; params: party, member, perm, new state.
    - OnInviteExpired(callback: (party: Party, player: Player) -> ()) – Fires on invite expiry (20s); params: party, player.

    Notes:
    - Leader defaults: CanKick=true, CanInvite=true.
    - Max members: 4 (default).
    - Invites expire: 20s.
    - Methods return true (success) or false (failure with warning).
    - Update Remotes module for client remotes.
]]--
10 Likes

You have no idea how perfect your timing was on this. Thank you

2 Likes

Scrolling through the code and the documentation, this is impressively thorough and well-considered. The API seems very intuitive (plenty of useful, clearly named methods and events without parameter bloat). This looks really nice!

iv been observing the code and saw your event module. the module is pretty simple, but its very un-optimized. you can optimize it by doing this:

  • making a linked list instead of using normal list.
  • another way is to make a optimized thread spawner.

if any questions, ask me or anyone else. love the module!