Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would I prevent the party board from allowing multiple players?

Asked by
yoshi8080 445 Moderation Voter
5 years ago

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)
0
You should be using local variables. User#19524 175 — 5y
1
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. User#19524 175 — 5y
0
so like using table.insert and table.remove? yoshi8080 445 — 5y

Answer this question