It’s an okay module, it be really helpful if you replicated the data to the client for GUI related stuff
Since you are using value objects anyway to store information you can just have the module use the value objects as references for data instead of using the OOP fields that don’t replicate
It probably also be helpful to have it when a member or leader leaves the game it updates the party info accordingly
Also its super strange to have the getparty function return a string “NoParty” why not just return it as nil?
otherwise I can’t do this
-- because a string value is considered a non-nil value the if statement passes
if partymodule:getParty(Player) then
print("Has party!")
end
Also you don’t change the CurrentMemberCount field when removing members, which makes it bug out after getting 4 invites accepted
function Party:addMember(Member: Player)
if self.CurrentMemberCount + 1 > self.MaxMembers then
warn(("[%s:%s] Cannot add %s to party. Too many members!"):format(Member.Name, self.CurrentMemberCount, self.MaxMembers))
return
elseif table.find(self.Members, Member) then
warn(("%s is already in the party."):format(Member.Name))
return
elseif table.find(self.Blacklist, Member) then
warn(("%s is blacklisted from the party!"):format(Member.Name))
return
end
table.insert(self.Members, Member)
self.CurrentMemberCount += 1
local newPhysicalMember = createNewInstance("ObjectValue", PhysicalParty.Members, Member.Name, Member)
newPhysicalMember:SetAttribute("Leader", false)
newPhysicalMember:SetAttribute("CanKick", false)
newPhysicalMember:SetAttribute("CanInvite", false)
end
function Party:removeMember(Member: Player)
if not table.find(self.Members, Member) then
warn(("%s not in the party."):format(Member.Name))
return
elseif self.Leader == Member then
warn("You cannot kick the leader from the party.")
return
end
table.remove(self.Members, table.find(self.Members, Member))
PhysicalParty.Members[Member.Name]:Destroy()
end