Party system help

So for my game I have a party system, I have implemented the basic functions.

Party Module:

local Party = {}

Party.CurrentParties = {}

function Party:Create(player) -- Player Instance: player
	local ID = player.UserId
	if player and not self.CurrentParties[ID] then
		self.CurrentParties[ID] = {}
		-- Creates party
		-- Fire a remoteEvent to update UI
	end
end

function Party:Disband(player) -- Player Instance: player
	local ID = player.UserId
	if self.CurrentParties[ID] then
		self.CurrentParties[ID] = nil
		-- Disbands party
		-- Fire a remoteEvent to update UI
	end
end

function Party:Leave(player) -- Player Instance: player
	for Host, Table in pairs(self.CurrentParties) do
		if table.find(Table, player) then
			table.remove(Table, table.find(Table, player))
			-- Player left party
			-- Fire a remoteEvent to update UI
		end
	end
end

function Party:Kick(host, playerToKick) -- Player Instance: host  | Instance: playerToKick
	local party = self.CurrentParties[host.UserId]
	table.remove(party, table.find(party, playerToKick))
	-- Kick player for party
	-- Fire a remoteEvent to update UI
end

function Party:Invite(host, playerToInvite) -- Player Instance: host  | Instance: playerToInvite
	if self.CurrentParties[host.UserId][playerToInvite.UserId] then return end
	-- Fire event to playerToInvite or remote funcitons? 
	-- Is it wierd to send it to client just to send it back, since I dont want to invoke the client from server.
	table.insert(self.CurrentParties[host.UserId], playerToInvite.UserId) -- If they accept
end

return Party

I have put comments on what I will do, though I have some questions that I need help with.
So most of the functions are pretty basic and I believe they shouldn’t break. As you can see in the Party:Invite() function I have a comment, now what would be the best way to approach this using a remote event or remote function?

Now I know it isn’t advised to use a remote function from the server to the client, but I think if I add enough checks it could work. So the information I get back from the client should only be a bool val of true or false. If true they accepted the invite. So I would check if the data I got from the client was a bool value and if it was true. Alternatively, I could fire a remote to client and have it sent back to the server. That’s my idea anyway if you have a better Idea let me know?

TL;DR
This is for the invite function:
Should I use RemoteEvent or RemoteFunctions?
Any other solution I could try?
Have I used any bad practice/ anything I should be doing?

I appreciate you took time to read this, hopefully this wasn’t too bad of a post. Just wanted to get other takes on the matter.

1 Like

You should use a RemoteEvent for that which should handle all the invite things;

Example:
The client will fire the server and provide any string (some key string that allows the server to understand they are inviting someone) as the first argument and the second as the Player invited, the server should check if this request makes sense (the client isn’t inviting itself, the invited player isn’t in the party already, the client isn’t in someone else’s party already, the invited player isn’t being invited by someone else at the moment, etc…), then if all the sanity checks verify the request is valid, you fire the invited player’s client with a certain argument and add them to some table with the invited player’s UserId (the client should display a gui or something appear which will allow them to choose if they want to be in the party or not), and once the decision is made - the invited player’s client fires the server with their choice (yes or no), if the player is found in the table, the choice is yes and they aren’t in the party already - you remove them from the table and add them to the party

that was a long one lol, yet it’s not really easily read sorry

1 Like

I appreciate that, I will work on that now, just needed to know which one to use and the correct way to use it. Thank you!

1 Like