How will you rate my party system for my pirate game?

Here I have my code which creates an int value with a name of a UUID that ensures each parties name will be different and can be accessed easily and changed easily. This code is for my pirate game hence why it is called “crews” but is really just parties. I am a bit new to the forum and am wondering what you more experienced scripters use for your party system and how it compares to mine?


local HttpService = game:GetService(“HttpService”)

local parties = game:GetService(“ServerStorage”):WaitForChild(“Parties”)

local PlayerObject = script:WaitForChild(“PlayerObject”)

–generate a party int value with the value being the amount of people inside the party and the name if a random UUID
function CrewService:CreateCrew(crewLeader)
local PartyObject = Instance.new(“IntValue”)
PartyObject.Name = HttpService:GenerateGUID(false)
PartyObject.Parent = parties
PartyObject.Value = 1

local PlayerObject = PlayerObject:Clone()
PlayerObject.Parent = PartyObject
PlayerObject.Name = crewLeader.Name
PlayerObject.IsLeader.Value = true
end

–removes a party member
function CrewService:RemoveCrew(crewmate)
local partyUUID = CrewService:GetUUID(crewmate)
if partyUUID then
parties[partyUUID]:Destroy()
end
end

–returns the UUID of the party given the party memeber
function CrewService:GetUUID(crewmate)
for _,party in pairs(parties:GetChildren()) do
if party:FindFirstChild(crewmate.Name) then
return party.Name
else
return false
end
end
end

–adds a party member object to the party intvalue and adds a isleader boolean to detect if they can kick people
function CrewService:AddCrewmate(crewmate, crewLeader)
local crew = CrewService:GetCrew(crewLeader)
if crew then
if crew.Value <= 4 then
local PlayerObject = PlayerObject:Clone()
PlayerObject.Parent = crew
PlayerObject.Name = crewmate.Name
PlayerObject.IsLeader.Value = false
end
end
end

–kicks party members by deleting the player object inside the party int value
function CrewService:KickCrewmate(crewmate)
local crew = CrewService:GetCrew(crewmate)
if crew then
local crewmember = crew:FindFirstChild(crewmate.Name)
if crewmember then
local leader = CrewService:GetCrewLeader(CrewService:GetCrew(crewmember))
if leader.Name ~= crewmember.Name then
crewmember:Destroy()
end
end
end
end

–returns the reference to the party int value that can be manipulated
function CrewService:GetCrew(crewmate)
local crewUUID = CrewService:GetUUID(crewmate)
if crewUUID then
local crew = parties:FindFirstChild(crewUUID)
if crew then
return crew
else
return false
end
end
end

–returns the crew leader if given the crew value
function CrewService:GetCrewLeader(crew)
for _,crewmember in pairs(crew:GetChildren()) do
if crewmember.IsLeader then
return crewmember
end
end
end

return CrewService
1 Like

Hello jake,

I looked over the code it looks good, But I was just wondering what it looked like in action could you also provide a picture/video of the party system?

I cant wait to see it if your able to upload a video! :slight_smile:

1 Like

Thanks for the input! Unfornately, I obly have the module but am planning to implement it soon.

1 Like