Party System | Need help with defining & suggestion

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I simply wanted to make a party system that use gui. I want to separate each function event for example, Create Party, Join Party, Leave Party. I made a code that creates folder ( Party ) and stringvalue ( player ) inside. Currently looking for solution about the issue.

  1. What is the issue? Include screenshots / videos if possible!

I want to check if player press the join party button and get party or partyfolder that player want to join into. I want to get the PartyFolder from “CreateParty” function that has local PartyFolder = Instance.new("Folder", Parties) and check player who press the button to join party.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Debris = game:GetService("Debris")
local Data = require(ReplicatedStorage.ModuleScripts.Data)
local PartySystemRemote = ReplicatedStorage.PartySystemRe
local HostAuthorityRemote = ReplicatedStorage.HostAuthorityRe
local Parties = ReplicatedStorage.Parties
local CloneFolder = ReplicatedStorage.CloneFolder

local scrollingframe

local host_POSITION = 1

local partylist = {}
local host, nonehost, member

local function UpdateParty(PartyFolder : Folder, player : Player)
	for i, v in pairs(PartyFolder:GetChildren()) do
		print("PLAYER INSIDE PARTY :", v)
		
		if v.Value == "Host" then
			print("HOST :", player)
			HostAuthorityRemote:FireClient(player, true)
		elseif v.Value == nil then
			print("NONE HOST :", player)
			HostAuthorityRemote:FireClient(player, false)
		end
	end
end

local function CreateParty(player : Player)
	
	local PartyFolder = Instance.new("Folder", Parties) -- CREATE
	PartyFolder.Name = "PartyFolder"
	
	local Player = Instance.new("StringValue", PartyFolder) -- CREATE
	Player.Name = player.Name
	Player.Value = "Host"

	for i, v in pairs(Parties:GetChildren()) do -- Change folder name and insert in table
		if v:IsA("Folder") then
			v.Name = i
		end
	end
	
	table.insert(partylist, PartyFolder)
	
	scrollingframe = player.PlayerGui.AllGui.PartyPage.PartyCreatePage.TextList.ScrollingFrame
	
	UpdateParty(PartyFolder, player)
	
	
end

local function JoinParty()
	-- This is where i want to check for player who join the party.
end

PartySystemRemote.OnServerEvent:Connect(function(player, PartyEvent)
	if PartyEvent == "Create" then
		CreateParty(player)
		print("PARTY LIST :", partylist)
	end
	
end)

I don’t want to follow some tutorial or get a model, because I want to practice myself with my own coding skill. If you can give me some suggestion or a fix. Please let me know.

Rather than using instances to save data just use tables. I’ll show you an idea and you can work around it.

Party table structure:

local Parties = {
[Player.UserId] = {
 010101, -- member ID's
020202
}
}
  1. Create party. A player will send an event to the server and the server will create a new table for the newly created party.
  2. Join party. You will get the player and the owners userid as a returned value. You will loop through the Parties table and check if an existing under the Owners userid does exist. If it does, you will add the players id onto the table.
  3. Leaving party. Check within all current parties to see if the player exists in one of em. If yes, remove their id from that parties table.

This is super simplified and its just a thought so you have to add your own stuff onto it

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.