I was planning to make a party system to teleport 4 players that join into a reserved server, but the first thing to start is to make a party system allowing players to fight together with the boss.
However, I'm not sure how what method should be done to allow players to only join once or so.
-- Join Party
Board = script.Parent.Parent.Board
PartyPlayers = Board:WaitForChild('PartyPlayers')
script.Parent.ClickDetector.MouseClick:Connect(function(player)
for i,v in pairs(PartyPlayers:GetChildren()) do
if v.Value == player then
else
end
end
if PartyPlayers.Player1.Value == nil then
PartyPlayers.Player1.Value = player
elseif PartyPlayers.Player2.Value == nil then
PartyPlayers.Player2.Value = player
elseif PartyPlayers.Player3.Value == nil then
PartyPlayers.Player3.Value = player
elseif PartyPlayers.Player4.Value == nil then
PartyPlayers.Player4.Value = player
end
end)
-- Leave Party
Board = script.Parent.Parent.Board
PartyPlayers = Board:WaitForChild('PartyPlayers')
script.Parent.ClickDetector.MouseClick:Connect(function(player)
for i,v in pairs(PartyPlayers:GetChildren()) do
if v.Value == player then
v.Value = nil
end
end
end)

3 comments
You should be using local variables.
You shouldn't be using crap tons of ObjectValues. You should have a table, and loop through the players, insert them into the table which will contain the party members.
so like using table.insert and table.remove?