Any ideas on how to make a party system?

Hi everyone, I’m making a game about going hiking and I want to create a party system. The party system lets you invite and kick players, the party never locks but just shows a gui on the players so you know where you party members are. Does anyone know how to script this, I’ve been trying to get it work with remote events but so far you can only invite yourself to the party, which is kind of stupid. Thanks

EDIT: you can also accept or decline the invite to the party

1 Like

Do players start with their own party or do they create one themselves? It would probably be easier if the player can create their own party without automatically owning one. What I would do is first have a system where players can create their own parties and either save their party through a data store or through some variables on the server. The owner should then be saved and the party should have a unique ID as a reference. I know you already have an invite system but when it comes to invites the player should be able to see a list of all the players in the game and invite them if they aren’t the owner or if they aren’t a part of the party already. You could reference a data store or the server variable that keeps the information about each party.

That’s an idea of how I would go about it. You can provide more information about the system and I may be able to come up with some more ideas.

Yes, Here is a script I made using only instances.

--Create a table to store the party members
local partyMembers = {}

--Create a RemoteEvent to invite players to the party
local inviteEvent = Instance.new("RemoteEvent")
inviteEvent.Name = "InviteEvent"
inviteEvent.Parent = game:GetService("ReplicatedStorage")

--Create a RemoteFunction to check if a player is already in a party
local checkPartyFunction = Instance.new("RemoteFunction")
checkPartyFunction.Name = "CheckPartyFunction"
checkPartyFunction.Parent = game:GetService("ReplicatedStorage")

--Create a RemoteEvent to kick players from the party
local kickEvent = Instance.new("RemoteEvent")
kickEvent.Name = "KickEvent"
kickEvent.Parent = game:GetService("ReplicatedStorage")

--Function to handle the invite event
function inviteEvent.OnServerEvent(inviter, invitee)
	--Check if the player being invited is already in a party
	if checkPartyFunction:InvokeClient(invitee) then
		--Return an error message if the player is already in a party
		inviter:Kick("Player is already in a party.")
	else
		--Add the player to the party
		table.insert(partyMembers, invitee)
		--Fire the event to update the party GUI for all members
		updatePartyEvent:FireAllClients(partyMembers)
	end
end

--Function to handle the check party function
function checkPartyFunction.OnServerInvoke(player)
	--Check if the player is in the party
	for i, member in ipairs(partyMembers) do
		if member == player then
			return true
		end
	end
	--Return false if the player is not in the party
	return false
end

--Function to handle the kick event
function kickEvent.OnServerEvent(kicker, kickee)
	--Remove the player from the party
	for i, member in ipairs(partyMembers) do
		if member == kickee then
			table.remove(partyMembers, i)
			--Fire the event to update the party GUI for all members
			updatePartyEvent:FireAllClients(partyMembers)
			return
		end
	end
end

Side Script:

--Get the RemoteEvent and RemoteFunction from the server
local inviteEvent = game:GetService("ReplicatedStorage").InviteEvent
local checkPartyFunction = game:GetService("ReplicatedStorage").CheckPartyFunction

--Create a GUI to display the party members
local partyGUI = Instance.new("ScreenGui")
local partyFrame = Instance.new("Frame")
local partyList = Instance.new("TextLabel")

--Set up the GUI elements
partyFrame.Parent = partyGUI
partyFrame.Size = UDim2.new(1, 0, 1, 0)
partyList.Parent = partyFrame
party

2 Likes

Is there any chance you could send the .rblx file with the uis? Thanks.

I did not make my own UI, all you have to do is insert this script into the frame. No work needed

Oh sorry my bad
character limit

If you need help you can watch tutorials. Thats how I learned.

Can you show me the code on the client when the InvokeClient is called?

How does the client invoke the invite event?

I would probably have to test it myself in Roblox Studio to see exactly why it isn’t working. It probably has something to do with how the invite system is written specifically the data being passed.

Fire on cmd, Which can be accessed throught the script.

1 Like

My code is a mess but basically I get the children of game.players and then use a loop to create a new text button with the name of the player. Then each button has a script inside of it which when it is clicked if fires a remote event with the values player and script.parent.name, it then goes to a server script which fires to all clients script.parent.name and then on a new localscript it says if local player name == the value fired to all clients show a gui. Yeah, it’s pretty awful.

Where is updatePartyEvent() defined?

Oh okay, that makes sense. You just fire the event on the client through the cmd passing in the value of the inviter and invitee.

I would probably take a look into the checkPartyFunction to see what value it is returning if you haven’t tested it already. It may have something to do with this.

Everything seems to be fine but I would check the data being passed into the checkPartyFunction, the value of the member, and the value of the invitee plus the player being passed in the checkPartyFunction. There is probably something going on there that is preventing anyone from joining besides yourself.

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