You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
a lobby system for my game. -
What is the issue? Include screenshots / videos if possible!
my lobby system isn’t working, multiple players cannot join my lobby. (and i can’t join theirs.) -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
…
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local Lobbies = {}
local LobbyMembers = {}
game.ReplicatedStorage.RecieveLobbies.OnServerEvent:Connect(function(Player, Action, Action2)
if Action == "Create" then
table.insert(Lobbies, Player.Name)
table.insert(LobbyMembers, {Player})
game.ReplicatedStorage.RecieveLobbies:FireAllClients(Lobbies, "Create", LobbyMembers)
end
if Action == "Disband" then
for i, Item in pairs(Lobbies) do
if Item == Player.Name then
table.remove(Lobbies, table.find(Lobbies, Item))
table.remove(LobbyMembers, table.find(Lobbies, Item))
game.ReplicatedStorage.RecieveLobbies:FireAllClients(Lobbies, "Disband", LobbyMembers)
end
end
end
if Action == "Begin" then
for i, Item in pairs(Lobbies) do
if Item == Player.Name then
local CustomID = game:GetService("TeleportService"):ReserveServer(72909619321737)
game:GetService("TeleportService"):TeleportToPrivateServer(72909619321737, CustomID, LobbyMembers[table.find(Lobbies, Player.Name)])
table.remove(Lobbies, table.find(Lobbies, Item))
table.remove(LobbyMembers, table.find(Lobbies, Item))
game.ReplicatedStorage.RecieveLobbies:FireAllClients(Lobbies, "Begin", LobbyMembers)
end
end
end
if Action == "Join" then
if Player.Name ~= Action2 then
table.insert(LobbyMembers[table.find(Lobbies, Action2)], Player)
game.ReplicatedStorage.RecieveLobbies:FireAllClients(Lobbies, "Join", LobbyMembers)
end
end
if Action == "Quit" then
if Player.Name ~= Action2 then
for i, Item in pairs(Lobbies) do
if Item == Action2.Name and table.find(LobbyMembers[table.find(i, Lobbies)], Player.Name) then
table.remove(LobbyMembers[table.find(i, Lobbies)], table.find(LobbyMembers[table.find(i, Lobbies)], Player.Name))
end
end
game.ReplicatedStorage.RecieveLobbies:FireAllClients(Lobbies, "Quit", LobbyMembers)
end
end
end)
game.Players.PlayerRemoving:Connect(function(Player)
for i, Item in pairs(Lobbies) do
if Item == Player.Name then
table.remove(Lobbies, table.find(Lobbies, Item))
table.remove(LobbyMembers, table.find(Lobbies, Item))
game.ReplicatedStorage.RecieveLobbies:FireAllClients(Lobbies, "Disband", LobbyMembers)
end
end
end)
global
local Enabled = true
game.ReplicatedStorage.RecieveLobbies:FireServer()
local Lobbies = {}
game.ReplicatedStorage.RecieveLobbies.OnClientEvent:Connect(function(LobbiesAlt, Action, LobbiesDuo)
Lobbies = LobbiesAlt
for i, obj in pairs(script.Parent.Parent.FriendLobby:GetChildren()) do
if obj:IsA("Frame") then
obj:Destroy()
end
end
for i, obj in pairs(Lobbies) do
local Line = game.ReplicatedStorage.LobbyItem:Clone()
local PlayerString = ""
for i, obj2 in pairs(LobbiesDuo[table.find(Lobbies,obj)]) do
PlayerString = PlayerString .. tostring(obj2)
if PlayerString == game.Players.LocalPlayer.Name then
script.Parent.TextTransparency = 0.5
Enabled = false
end
end
Line.Players.Text = "Players: " .. PlayerString
Line.Parent = script.Parent.Parent.FriendLobby
Line.Creator.Value = game.Players:FindFirstChild(obj)
if string.sub(obj, #obj):upper() == "S" then
Line.Title.Text = obj .. "' Lobby"
else
Line.Title.Text = obj .. "'s Lobby"
end
end
if Action == "Disband" then
script.Parent.TextTransparency = 0
Enabled = true
for i, obj in pairs(Lobbies) do
if obj == game.Players.LocalPlayer.Name then
script.Parent.TextTransparency = 0.5
Enabled = false
end
end
end
end)
script.Parent.MouseButton1Click:Connect(function()
if Enabled == true then
game.ReplicatedStorage.RecieveLobbies:FireServer("Create")
end
end)
local
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.