I’m making a horror game type gui lobby where you can create a lobby for people to join, I have a button that would create the lobby but I’m pretty confused on how to make the lobby you create show up for other players.
I’m not sure if I would do this server sided or client sided, I was thinking when the player presses the create lobby button the little lobby tab template I made would clone and turn visible but I don’t know if that will work or if there is a better way to do it, if I did do that I don’t know if I would use a server script or local script.
And one more thing I don’t know how I would change the text for the lobby tab for example changing the “Lobby Name” to “Player’s Lobby”. To be clear I do know how to change text on a gui through a script but I don’t know how to make it show for everyone.
To make lobby names show for everyone, just pass in the name with the lobby data as the client loads the lobby menu, and do the same for when a new lobby is created (however you update it).
As for creating lobbies, I would have the GUI setup on the client, but I’d also fire an event to the server, to request creating a lobby. Make sure you sanity check everything the client sends in this event.
If it fails, you can send the player back to the lobby list from the server, just so they don’t get stuck on a broken lobby screen.
I’m assuming here that the server has an array of all the active lobbies.
I created something similar to this, and there’s a surprising amount that goes on behind the scenes, in order to change the test specifically for the whole server, you need to do a :FireSever() through a remote event in replicated storage.
An example of this would be this:
local Button= script.parent local Event = game:getservice(“ReplicatedStorage”)
This makes it so that a sever event would be fired from a local script within a button and on the recipient side you could do a :OnSeverEvent() and change the text with a script. Although there is much more at play, especially with script accessibility to the events, for my system, there was an absurd amount of events used, so if you need any further help, then just reply!
If you wanted to make the lobby name of the player, then you can use players’ names through this little trick of saying :firesever(player.name) wich should get the player name sent and can be received on the event, this works for pretty much anything.
So, I figured out what I was trying to do, for some reason changing the visibility and text through a server script only changed it for the player creating the lobby, So I fired a server event like you said and then used another remote event to fire all clients then changed the visibility and stuff through a local script so it changes for all players.
And you were right so far its taking alot of remote events for everything.
I ran into a new problem now, as I said before I used a server script and used FireAllClients() since changing the gui inside of the server script didn’t work. Now when creating a lobby it shows for everyone but it creates as many lobbies as there are people in the game and I’m guessing that’s because it fires all clients.
The local script inside the button that creates the lobby:
local button = script.Parent
local RS = game:GetService("ReplicatedStorage")
local Player = game.Players.LocalPlayer
local debounce = false
button.MouseButton1Down:Connect(function()
if debounce == false then
debounce = true
local lobbyRemotes = RS:FindFirstChild("LobbyRemotes")
local createLobbyEvent = lobbyRemotes:FindFirstChild("CreateLobby")
createLobbyEvent:FireServer(Player)
local PlayerGui = Player:FindFirstChild("PlayerGui")
local LobbyCreateGui = PlayerGui:FindFirstChild("LobbyCreateGui")
local LobbyMenuGui = PlayerGui:FindFirstChild("LobbyMenuGui")
LobbyMenuGui.Enabled = false
LobbyCreateGui.Enabled = true
debounce = false
end
end)
The server script that Fires all the clients
local RS = game:GetService("ReplicatedStorage")
local lobbyRemotes = RS:WaitForChild("LobbyRemotes")
local createLobbyEvent = lobbyRemotes:WaitForChild("CreateLobby")
createLobbyEvent.OnServerEvent:Connect(function(Player)
local UpdateLobbyListEvent = lobbyRemotes:FindFirstChild("UpdateLobbyList")
UpdateLobbyListEvent:FireAllClients(Player)
end)
The local script that updates the gui for all players
local RS = game:GetService("ReplicatedStorage")
local lobbyRemotes = RS:WaitForChild("LobbyRemotes")
local UpdateLobbyListEvent = lobbyRemotes:WaitForChild("UpdateLobbyList")
local Players = game:GetService("Players")
local Player = game.Players.LocalPlayer
UpdateLobbyListEvent.OnClientEvent:Connect(function(Plr)
local PlayerGui = Player:FindFirstChild("PlayerGui")
local LobbyMenuGui = PlayerGui:FindFirstChild("LobbyMenuGui")
local LobbyList = LobbyMenuGui:FindFirstChild("LobbyList")
local LobbyTab = LobbyList:FindFirstChild("LobbyTabTemplate")
local LobbyHeadshot = LobbyTab:FindFirstChild("PlayerHeadshot")
local userId = Plr.UserId
local HeadshotThumbnail = Players:GetUserThumbnailAsync(userId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size100x100)
local LobbyCreateGui = PlayerGui:FindFirstChild("LobbyCreateGui")
local LobbyTabClone = LobbyTab:Clone()
LobbyTabClone.Name = Plr.Name
LobbyTabClone.Parent = LobbyList
LobbyTabClone.LobbyName.Text = Plr.Name.."'s Lobby"
LobbyHeadshot.Image = HeadshotThumbnail
LobbyTabClone.Parent = LobbyList
LobbyTabClone.Visible = true
end)
Yes, that would be, as the fire clients would happen for everyone, for this instance, I would clone the GUI into the sever select area, and then check if the player. name is equal to the player.name for that player this makes it so only the player who created the lobby can only be the one seen, as you are filtering the client event to that direct player. I see that you have fired the player “:OnSeverEvent(player)” in the severevent, so you can carry it over to the client event to use it there.
local button = script.Parent
local RS = game:GetService("ReplicatedStorage")
local Player = game.Players.LocalPlayer
local debounce = false
button.MouseButton1Down:Connect(function()
if debounce == false then
debounce = true
local lobbyBindables = RS:FindFirstChild("LobbyBindables")
local createLobbyEvent = lobbyBindables:FindFirstChild("CreateLobby")
createLobbyEvent:Fire(Player)
local PlayerGui = Player:FindFirstChild("PlayerGui")
local LobbyCreateGui = PlayerGui:FindFirstChild("LobbyCreateGui")
local LobbyMenuGui = PlayerGui:FindFirstChild("LobbyMenuGui")
LobbyMenuGui.Enabled = false
LobbyCreateGui.Enabled = true
debounce = false
end
end)
local RS = game:GetService("ReplicatedStorage")
local lobbyBindables = RS:WaitForChild("LobbyBindables")
local createLobbyEvent = lobbyRemotes:WaitForChild("CreateLobby")
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
createLobbyEvent.Event:Connect(function(Plr)
local PlayerGui = Player:FindFirstChild("PlayerGui")
local LobbyMenuGui = PlayerGui:FindFirstChild("LobbyMenuGui")
local LobbyList = LobbyMenuGui:FindFirstChild("LobbyList")
local LobbyTab = LobbyList:FindFirstChild("LobbyTabTemplate")
local LobbyHeadshot = LobbyTab:FindFirstChild("PlayerHeadshot")
local userId = Plr.UserId
local HeadshotThumbnail = Players:GetUserThumbnailAsync(userId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size100x100)
local LobbyCreateGui = PlayerGui:FindFirstChild("LobbyCreateGui")
local LobbyTabClone = LobbyTab:Clone()
LobbyTabClone.Name = Plr.Name
LobbyTabClone.Parent = LobbyList
LobbyTabClone.LobbyName.Text = Plr.Name.."'s Lobby"
LobbyHeadshot.Image = HeadshotThumbnail
LobbyTabClone.Parent = LobbyList
LobbyTabClone.Visible = true
end)
I did this using 2 local scripts but it’s only cloning the GUI to the player that created the lobby, any idea why this is happening?
(And sorry for the trouble)
local button = script.Parent
local RS = game:GetService("ReplicatedStorage")
local Player = game.Players.LocalPlayer
local debounce = false
button.MouseButton1Down:Connect(function()
if debounce == false then
debounce = true
local lobbyBindables = RS:FindFirstChild("LobbyBindables")
local createLobbyEvent = lobbyBindables:FindFirstChild("CreateLobby")
createLobbyEvent:Fire(Player)
local PlayerGui = Player:FindFirstChild("PlayerGui")
local LobbyCreateGui = PlayerGui:FindFirstChild("LobbyCreateGui")
local LobbyMenuGui = PlayerGui:FindFirstChild("LobbyMenuGui")
LobbyMenuGui.Enabled = false
LobbyCreateGui.Enabled = true
debounce = false
end
end)
local RS = game:GetService("ReplicatedStorage")
local lobbyBindables = RS:WaitForChild("LobbyBindables")
local createLobbyEvent = lobbyBindables:WaitForChild("CreateLobby")
local Players = game:GetService("Players")
local Plr = Players.LocalPlayer
createLobbyEvent.Event:Connect(function(Player)
local PlayerGui = Plr:FindFirstChild("PlayerGui")
local LobbyMenuGui = PlayerGui:FindFirstChild("LobbyMenuGui")
local LobbyList = LobbyMenuGui:FindFirstChild("LobbyList")
local LobbyTab = LobbyList:FindFirstChild("LobbyTabTemplate")
local LobbyHeadshot = LobbyTab:FindFirstChild("PlayerHeadshot")
local userId = Player.UserId
local HeadshotThumbnail = Players:GetUserThumbnailAsync(userId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size100x100)
local LobbyCreateGui = PlayerGui:FindFirstChild("LobbyCreateGui")
local LobbyTabClone = LobbyTab:Clone()
LobbyTabClone.Name = Player.Name
LobbyTabClone.LobbyName.Text = Player.Name.."'s Lobby"
LobbyHeadshot.Image = HeadshotThumbnail
LobbyTabClone.Visible = true
LobbyTabClone.Parent = LobbyList
end)
Just want to check if the event fires. Is the path directory correct? If so, could you try printing something below createLobbyEvent.Event? Oh and sorry for the late response.