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)