Hey everyone! I’ve decided to work and script a working lobby model. This model is similar to the lobbies in Roblox Doors, tower defense games, etc. I’ve worked very hard on this model to bring the following features to this model:
Countdown starts only when a player enters, and keeps going unless everyone leaves the lobby.
Very detailed tutorial on each script for beginner scripters who wouldn’t understand what something means in the scripts (To see the tutorial, it’s a script in the model named “READ ME”).
When a player enters the lobby, their camera will change to being in front of the lobby door.
Script explains what important lines of code in the script does, with it showing the ability to remove some features in the script that you may dislike.
If the lobby reaches max amount of people, then if the timer isn’t already less than or equal to 5 seconds, it will set the timer to 5 seconds (The script shows you how to change it if you wanted to).
Many debounces and checks to ensure the player cannot somehow glitch it, making it glitch proof (Many tests were made to ensure this).
Teleporting GUI with a cool three dot movement that bounce up and down in order, also ensured that the GUI is compatible with all devices, so it doesn’t look funky on other devices.
This is compatible with all devices, except maybe consoles… I don’t know how consoles work if I’m going to be honest.
Very easy to set up, very easy to work with, as long as you read through the “READ ME” script, then everything should work. If you skim through the “READ ME” script, it will be very hard to set up, and a huge chance that the model would not work as intended.
Advanced Scripters:
You are free to make any changes or addons you’d like, such as a door closing while the players are being teleported. The script is already programmed so that while players are being teleported, then other players cannot go in the lobby until the teleportation is complete.
All Scripters:
Just as the dev forum and the community has helped me through so much, and they’re basically mostly the reason how I’ve learned this much and become this more advanced, I wanted to do this to give back to you guys for how much help you guys have been.
Beginner + All Scripters:
Hopefully the “READ ME” script is enough to help new scripters learn from this instead of just using it without learning anything. I tried making this as easy as possible for all levels. Thank you all again for always helping me when I ask a question on the dev forum, and also when I find answers on the dev forum.
Hello! There’s one bug in the script, but only one that I have found! It’s very easy to fix, as all you are doing is moving a line to another line. For those who have already made edits to your scripts, the line is probably different. You can insert a new model to compare the script to see what line to change.
On line 185, there should be a “debounce = false”. Now, there should be three “ends” under that. Move the debounce under the FIRST end, so there should be one end over it, and two ends below it. The bottom end has a “)” on the right of it.
Reason for this change:
In case the player was detected, it’d wait three seconds or until the player was added to the list. Problem was, it’d start the debounce anyways after that. But because (very rarely) that list was not over 1, it’d skip the if and the whole function would end. But now debounce can’t go back to being false because of the “if not debounce then”. So, we want to move the debounce = false under the “if list >= 1” if statement so then if the list didn’t turn 1 or above in three seconds, the debounce would just go back to false.
this is literally AMAZING stuff like this are why roblox studio is really beginner friendly and will attract a lot of game devs and inspire younger people to get into game development. Appreciate your work so much.
no errors unfortunately, the elevator doesn’t initiate count down and doesn’t teleport but it does show the accurate number of people in it. When the person causing the error exits the elevator it starts working properly again.
Sounds like this would be a rare issue but it happens every day multiple times
I will pay if somebody can fix this for me as soon as possible! Thanks!
Hey! I tried adding a “minimum player” ability, and it works for me so far, but it is no longer playtested and bugs or glitches may occur. Be advised.
*note that I may have accidentally added a space or a print somewhere, line numbers might not match up
At line 127, the script.Parent.Gate.Touched:Connect(function(hit) function/connection is responsible for teleporting players.
Go to line 143, and you will see the following:
change the >= 1 into a >= 2
collapse the function by clicking the arrow near the line number to see this
insert a new line below, and add
wait(1)
debounce = false
to get this:
without resetting the debounce back to false, the countdown won’t start
note that this is a very basic way of dealing with it and might add bugs and/or glitches.
if anybody wants to change this and improve on it, please do so, this is pretty bad lol
if you want just the whole function here:
before you copy note that I changed max people to 3 so if yours is different make sure to correct
New function
script.Parent.Gate.Touched:Connect(function(hit)
if #list >= 3 then return end -- Set number to max amount of people in a lobby
if teleporting == true then return end
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player == nil then return end
if player ~= nil and debounce2 == false then ------------------------ This will change the player's camera to
game.ReplicatedStorage.CameraEvent1:FireClient(player) -- (()) -- the teleport block's camera, so then the
end ----------------------------------------------------------------- players can see themselves in the lobby.
-- Delete if you don't want that.
timer2 = 300
repeat
task.wait(0.01)
timer2 = timer2 - 1
until timer2 == 0 or #list >= 1
if not debounce then
debounce = true
if #list >= 2 then
timer = 5 --[[ Set to how much time the timer should run down when the first person joins.
It is recommended to set the timer to 30 if the max amount of players for the -
lobby is two players or more. It is also recommended to just set it to 5 if -
it's a one player lobby. ]]
timer3 = 9
repeat
script.Parent.timer.billboardGui.timer.Text = timer
if #list == 3 then -- Change to max amount of players ------------ This makes it so that if the lobby
if timer > 5 then -------------------------------------------- reaches the max amount of people,
if something == false then ------------------------------- then if the timer isn't already equal
timer = 5 -------------------------------------------- to or less than 5 seconds, it will set
script.Parent.timer.billboardGui.timer.Text = timer -- it to 5 seconds. It is heavily
something = true ------------------------------------- recommended to keep this so then max
end ------------------------------------------------------ lobbies don't have to wait the whole
end ---------------------------------------------------------- countdown. If you do not want this,
end -------------------------------------------------------------- you may delete these 9 lines of code.
if timer <= 1 then -------------------------------------------------- This will remove the leave button
if something2 == false then ------------------------------------- a second before the count down ends.
game.ReplicatedStorage.LeaveGuiTimerOff:FireClient(player) -- It is heavily recommended you keep it
something2 = true ------------------------------------------- as it will prevent leave glitching.
end ------------------------------------------------------------- If you don't want it, you can delete
end ----------------------------------------------------------------- these 6 lines of code.
repeat
timer3 = timer3 - 1
task.wait(0.1)
if #list <= 0 then timer = 0 break end
until timer3 <= 0
timer3 = 9
timer = timer - 1
if #list <= 0 then
timer = 0
script.Parent.timer.billboardGui.timer.Text = ""
updateGui()
end
until timer == 0
teleportPlayers(player)
something = false
something2 = false
debounce = false
end
wait(1)
debounce = false
end
end)
Hope I helped you, reach out if this doesn’t work and I will try to help!
I can’t begin to tell you how useful this has been for helping me make my lobby. The step by step instructions are very clear and so far I haven’t had a single problem. Resources like this are a HUGE help for solo developers like myself where its hard to find people who want to be hired or ask for help. This is a great kindness for the dev community and I hope it will continue to help creators like me.