#Trying to make a pong game: How do i create a party system? (beginner)

48 messages · Page 1 of 1 (latest)

warm pasture
#

Hey, I was wondering how I could make a sort of party system where, when two players enter an elevator, it begins the game, making their screen black and making them being able to control a paddle each?

part = script.Parent
tp = script.Parent.Parent.ElevatorTeleport

local playerList = {}
local debounce = nil

part.Touched:Connect(function(hit)
    print(hit.Parent.Name)
    print(#playerList)
    print(playerList)
    local humanoid = hit.Parent:WaitForChild("Humanoid")
    
    if humanoid and debounce == nil and #playerList < 2 then
        local playerName = hit.Parent.Name
        local humrootpart = hit.Parent:WaitForChild("HumanoidRootPart")
        
        
        debounce = 0
        if #playerList == 0 then -- assigns the first player that touches the part
            table.insert(playerList, playerName)
            humrootpart.Position = tp.Position + Vector3.new(0, 1, 0)
        else
            for _, player in pairs(playerList) do
                if player == playerName then -- if player already in the list
                    print("Player already in list")
                    
                else -- otherwise he can join the elevator
                    table.insert(playerList, playerName)
                    humrootpart.Position = tp.Position + Vector3.new(0, 1, 0)
                end
            end
        end
        task.wait(1)
        debounce = nil
    else
        return "Not a player!"
    
    end
    
    
end)
crimson rune
#

you mean you want to make a lobby like from the game doors to enter another place?

warm pasture
warm pasture
#

should I make people teleport to another place

#

or should I instantly make them play the game

crimson rune
crimson rune
#

i think

warm pasture
#

how could I assign a paddle to each player?

warm pasture
#

do I need to use onclientserver and fireserverthen?

crimson rune
warm pasture
#

not with 3 though so idk

#

but it does print the intended list

crimson rune
#

you probably should beacuse it would teleport eveyone to the tppart

warm pasture
#

uhh

#

well I made it so only the player that touches the part gets teleported

#

since the humanoid root part is taken from hit.Parent

crimson rune
#

oh wait i understand

#

i never thought about doing that

warm pasture
#

ohh

#

I guess we learn something every day

#

is that a good way to do it?

warm pasture
#

so does anyone know?

warm pasture
#

@woven agate hey sorry to bother you again, could you look at how I could make the system I want?

#

youd on't have to

woven agate
#

I don’t actually know how to 💀

#

You could look up a tutorial

#

But I haven’t really done something like a party system before

warm pasture
#

thanks anyway man

warm pasture
#
part = script.Parent
tp = script.Parent.Parent.ElevatorTeleport

local Players = game:GetService("Players")

local playerList = {}
local debounce = nil

local RunService = game:GetService("RunService")
local TeleportService = game:GetService("TeleportService")

local TARGET_PLACE_ID = 18757649511 -- game id

local tempTP = script.Parent.TestTP


playersReady = false

part.Touched:Connect(function(hit)
    
    local character = hit.Parent
    local humanoid = character:FindFirstChild("Humanoid")

    if humanoid and debounce == nil and #playerList < 2 then
        local player = Players:GetPlayerFromCharacter(character)
        
        local playerName = hit.Parent.Name
        local humrootpart = hit.Parent:WaitForChild("HumanoidRootPart")


        debounce = 0
        if #playerList == 0 then -- assigns the first player that touches the part
            table.insert(playerList, playerName)
            humrootpart.Position = tp.Position + Vector3.new(0, 1, 0)
        else
            for _, player in pairs(playerList) do
                if player == playerName then -- if player already in the list
                    print("Player already in list")

                else -- otherwise he can join the elevator
                    table.insert(playerList, playerName)
                    humrootpart.Position = tp.Position + Vector3.new(0, 1, 0)
                end
            end
        end

        task.wait(1)
        debounce = nil
    else
        return "Not a player!"

    end


end)
#

local function teleportPlayers(list)
    local teleportOptions = Instance.new("TeleportOptions")
    teleportOptions.ShouldReserveServer = true
    for i, playerName in pairs(list) do
        local player = Players:FindFirstChild(playerName)
        if player then
            TeleportService:Teleport(TARGET_PLACE_ID, player)
        end
    end
    playersReady = false
    
end


local function countdown(timer)
    for i = timer,0,-1 do
        print(i)
        task.wait(1)
    end
    teleportPlayers(playerList)
end



RunService.Heartbeat:Connect(function()
    if #playerList == 2 and not playersReady then
        playersReady = true
        countdown(5)
    end
end)
#

probably not the best way but I don't care since it's only gonna be the lobby

woven agate
#

Yeah it looks fine to me

warm pasture
#

I tweaked it a little now it detects when a player leaves in the middle of the teleportation

warm pasture
#

I have an issue it's weird

#

wait I'll just ping you real quick

woven agate
#

Yeah

#

Not sure when I can respond but I’ll try