Lobby System/Party System

Work on making it so it requires 3 people to be on the tp pad “then locks it once 3 ppl are on” and it gives 10 seconds once the three people are on until they tp to the first level, but there is an exit button (as a screen gui) so if someone in the tp pad clicks it they get tped out of the pad and the timer stops until someone else joins and it is 3/3 again

I’m trying to make a game with my friend that requires a lobby/party up system. I have no idea how to do this. Help is appreciated.

Just clearing things up, I’m not asking for the script just send me the api references, or a devhub link. I like to puzzle it together myself.

Do you have any scripting knowledge? Usually in this kind of situation I’d use Object Oriented Programming to create a platform class and then have a property for each class object using Tables that tracked the amount of people on the platform. However, what I just said is pretty vague and most likely won’t help you that much.

Here are some of the necessary instances and scripting knowledge you’ll most likely need for this project:

Several things you’ll want to include are detection for players already in the table (players on the platform), detection for when a player leaves the platform, and the necessary cleanup that occurs when you teleport the players to another place. The first one can be accomplished with the BasePart.Touched event, the second with the ClickDetector, and the third with the table.clear function. Hope I helped you get started!

2 Likes

I’ve been reading through these articles. I just need help with one thing (maybe I looked over this when reading), but using the .touched event to see when a player steps on it, and the .touchended to see when they step off the platform. How can I insert the player’s name into a table, and remove it when they step off, and if there are enough players for the game to start it’ll teleport them to the game.

I mentioned the ClickDetector because I thought you’d have it set up where you touched an invisible part to join the party and pressed a button to leave it. If I were you I recommend not using BasePart.TouchEnded because if it is set up in sync with BasePart.Touched then people who are already on the platform might keep switching between being in the party and not being in it. Alternatively, if you don’t want to have a button the player presses you can instead use the same part they touched to join the lobby to leave it if they touch it again.

I was envisioning that you wanted something like this
Screen Shot 2021-05-19 at 4.20.47 PM
With the black wall part as the part to touch to get into the lobby and the button what you press to get out of it.

1 Like

So when they enter into the platform would I put their names into a table, and if it gets 3 it tps them. How would I get their names into the table, and remove them if they click the exit button.

You could do something like this:

local Players = game:GetService("Players") -- The players service
local TeleportService = game:GetService("TeleportService") -- the service to teleport the players to another place

local lobby = {}

local door = PathToDoor -- This is an example variable meant to be the door
local platform = PathToPlatform -- This is an example variable meant to be the platform
local button = PathToButton:FindFirstChildOfClass("ClickDetector") -- This is an example variable meant to be the buttons Click Detector

button.MouseClick:Connect(function(playerInstance)
    local check = table.find(lobby, playerInstance)
    if check then
        table.remove(lobby, playerInstance)

        hit.Parent:SetPrimaryPartCFrame(CframeOutsideLobby) -- The cframe that is not on the platform
    end
end)

door.Touched:Connect(function(hit)
    local check = Players:GetPlayerFromCharacter(hit.Parent)
    if check and #lobby < 3 then
        table.insert(lobby, check)

        hit.Parent:SetPrimaryPartCFrame(platform.CFrame + Vector3.new(0,4,0))

        if #lobby == 3 then
            TeleportService:TeleportAsync(examplePlaceId, lobby) -- The place ID of the game you want to teleport the players to
        end
    end
end)

Note: This is example code. It is untested.

3 Likes

At the local check = Players:GetPlayerFromCharacter(hit.Parent) I get attempt to call nil value in output.

Hmm. That shouldn’t be happening. I doubt it’s a problem with that line though. Try replacing it with this:

door.Touched:Connect(function(hit)
    if hit.Parent:IsA("Model") and hit.Parent:FindFirstChildOfClass("Humanoid") then
        local check = Players:GetPlayerFromCharacter(hit.Parent)
        if check and #lobby < 3 then
            table.insert(lobby, check)

            hit.Parent:SetPrimaryPartCFrame(platform.CFrame + Vector3.new(0,4,0))

            if #lobby == 3 then
                TeleportService:TeleportAsync(examplePlaceId, lobby) -- The place ID of the game you want to teleport the players to
            end
        end
    end
end)