#how to i make an code for private lobbys so freinds can join the game only with the code?
1 messages · Page 1 of 1 (latest)
hello so after you have a private server with reserved code, if you want other people to see the code you can use a memorystore to save a code and a reserved server code to go along with it
assuming this is from no scripting experience its gonna do something like this
what?
ok but for what is the code? the generation of the code or the joining?
so, what is your issue
i have this
so what happens when the remote is fired
and this
what remote?
no the roblox ai
oh
** You are now Level 4! **
okay so your second script PlayerCountAndCodeGui
this?
oh wait maybe
is your RequestJoinCode remote being used anywhere?
do you have more scripts
i can't script so i used the ai
no
okay so where are you saving the join codes
well yes but for other things
idk
or do you mean were i can see the code in game?
no im just wondering so
you createdthe server
and presumably you saved the join code somewhere, right?
yes i think
okay so
my question is
in replicatedstorage you have RequestJoinCode and SendJoinCode
so, what exactly is your game going to have for the join code system?
is it like, when someone creates a lobby and then starts, a join code is made which people can join from the lobby?
or, is it going to be like doors where you go into a lobby, people join, and then you start
?
i can send a video how its supposed to go along if that helps
A: a party system, where people join and then you teleport
or is it
B: a **server system, where you teleport and then people join **
sure
okay
my question is
in the actual game it makes te code right
it makes a code but where does it save the code so that you can use it
i don't realy know
i think thats it
this?
wait no
that were the generation is
in the game were its supposed to teleport you
yeah
was that right?
ok the code is in the exact same game
oh
?
so can i see where the code is generated
because if its not saved anywhere then people wont be able to join
there should be a script that makes the code
i think that was the code
i told the ai to make it in that script
i see
but
there should be a script in serverscriptservice
that actually generates the join code
is there one there
oh wait i found a diferrent code
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RequestJoinCode = ReplicatedStorage:WaitForChild("RequestJoinCode")
local SendJoinCode = ReplicatedStorage:WaitForChild("SendJoinCode")
local playerCodes = {}
-- Funktion zum Generieren eines zufälligen 6-stelligen Codes
local function generateCode()
local chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
local code = ""
for i = 1, 6 do
local rand = math.random(1, #chars)
code = code .. string.sub(chars, rand, rand)
end
return code
end
Players.PlayerAdded:Connect(function(player)
-- Generiere einen eindeutigen Code für den Spieler
local code
repeat
code = generateCode()
until not playerCodes[code]
playerCodes[code] = player.UserId
-- Optional: Sende den Code direkt an den Spieler (z.B. per Chat)
player:LoadCharacter()
player:WaitForChild("PlayerGui")
-- Sende Code an Client, wenn angefragt
end)
Players.PlayerRemoving:Connect(function(player)
-- Entferne den Code, wenn der Spieler das Spiel verlässt
for code, userId in playerCodes do
if userId == player.UserId then
playerCodes[code] = nil
break
end
end
end)
-- RemoteEvent: Client fragt seinen Code an
RequestJoinCode.OnServerEvent:Connect(function(player)
for code, userId in playerCodes do
if userId == player.UserId then
SendJoinCode:FireClient(player, code)
return
end
end
-- Falls kein Code gefunden, generiere einen neuen
local code
repeat
code = generateCode()
until not playerCodes[code]
playerCodes[code] = player.UserId
SendJoinCode:FireClient(player, code)
end)
thats in and normal script
okay so just to let you know
you can format your code
print("like this")
by going like
```lua
print("Code here!")
```
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RequestJoinCode = ReplicatedStorage:WaitForChild("RequestJoinCode")
local SendJoinCode = ReplicatedStorage:WaitForChild("SendJoinCode")
local playerCodes = {}
-- Funktion zum Generieren eines zufälligen 6-stelligen Codes
local function generateCode()
local chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
local code = ""
for i = 1, 6 do
local rand = math.random(1, #chars)
code = code .. string.sub(chars, rand, rand)
end
return code
end
Players.PlayerAdded:Connect(function(player)
-- Generiere einen eindeutigen Code für den Spieler
local code
repeat
code = generateCode()
until not playerCodes[code]
playerCodes[code] = player.UserId
-- Optional: Sende den Code direkt an den Spieler (z.B. per Chat)
player:LoadCharacter()
player:WaitForChild("PlayerGui")
-- Sende Code an Client, wenn angefragt
end)
Players.PlayerRemoving:Connect(function(player)
-- Entferne den Code, wenn der Spieler das Spiel verlässt
for code, userId in playerCodes do
if userId == player.UserId then
playerCodes[code] = nil
break
end
end
end)
-- RemoteEvent: Client fragt seinen Code an
RequestJoinCode.OnServerEvent:Connect(function(player)
for code, userId in playerCodes do
if userId == player.UserId then
SendJoinCode:FireClient(player, code)
return
end
end
-- Falls kein Code gefunden, generiere einen neuen
local code
repeat
code = generateCode()
until not playerCodes[code]
playerCodes[code] = player.UserId
SendJoinCode:FireClient(player, code)
end)
okay so
theres a small issue with your code
whats the problem?
no it shouldn't
ok
okay so let me just clarify
i think your code
makes the join code BEFORE the server starts, right?
oh wait
OK
I Understand now!
btw the code manager is in the serverscriptservice is that right?
yes
so the reason your code isnt working is because
the code is being generated in the hosting place
but since its in that place it cant be moved over to the lobby
so you have to use messagingservice or memorystoreservice to get the code
and then teleport to the reservedserver
k so
this level of scripting is a bit complicated for just the ai assistant to handle
please explain it to me in monkey terms so i can understand
oooh
theres person there who give piece of paper
with the code on it
but telephone hasnt been invented yet
yes
** You are now Level 5! **
does that hinder anything to the code?
uh not really
ok
well, from what i understand the ai assistant didnt really help with anything
if you want you can add me into team create and i can try to fix the join system
yes please
fire_fox98395
okay
and as a thanks i will give you mod rolle with credits if the game comes out some time
nah you dont have to
ok
so first
i see the main issue
the assistant thought by code you were talking about the actual RESERVED SERVER code...
which means it can teleport fine if you put in a reserved server code
?
basically
you have two codes for the game
- your code which is 6 letters and lets people join
and
- your code which directly lets you into the server through scripts
so it could teleport me but it can't cuz of the key
what code?
reserved server access code
i have an idea on how to get the code though
ill be done in like 5 mins and then it should work
ok
wdym module?
modulescripts basically just allow you to make your game more easy to understand so
i like that
you would have a module in replicated storage named like LobbySystem
ok
ill say more when i get home in like 5 minutes
ok
but it just makes stuff easier for you
PepeWowCry i realy like that
modulescripts make beginner's life extremely easier
instead of getting chatgpt to write like 50 scripts you just do smt like
CodeManager:TeleportToCodePlace("R93KS")
clean and simple so you can do like module:createlobby(lobby settings)
module:.oinlobby(code)
module:listpubliclobbies() etc
ok
ill make something for you in like 15 minutes and i can probably finish it in like 15 minutes so in 30 monutes ill have sometting for you
ohh my god 😭
ok ty i will also give you mod role
** You are now Level 8! **
is that a problem?
maybe
i js do stuff for fun its fine
no please take that
okk
i told the ai to just disable the gui and enable the other gui
im thinking of making a thing with the chatgpt api that just basically makes devs lifes 10x easier
wdym
sorry it was off topic
ok
its a plugin ima make
is that like that one nvidia thing ai that you can make games with with out rally code?
but just a differeent one?
@astral cave i think its done
ok ima test it
if it doesnt work press F9 and go to server and see if anythings there
and the log is empty
whats the error
idk it was empty
what was it?
wdym you forgot?
went to write something else then forgot
oh ok
i deleted the code that checks if its valid
isnt neccessary
try going into the game my code is PH60T4
what error
whattt
or did you leave?
no i didnt leave
ok
hang on
k
you teleported?
yes
back
hi
did it work?
let me ese
?
ok
ohh
i know whats happening
each person gets a unique code
that shouldn't happen
how is that possible?
i dont know
try making a new server
wait
no
ill make it
try joining 9K5YM0
you mean a naw game?
oh ok
if it doesnt work press F9 and go to server
tell me anything thats there
like this
;_;
????
my server detected the message to get the code
but your server didnt detect the message back
erm
idk
show code
oh i know whats happening!
idk i think switch is editing it
wants to use server codes to join reserved servers, the problem is there was no code to even handle generating codes
peak
i need the code
oh wait
** You are now Level 6! **
tysm for the help
ok
add solved tag i guess
i dont really need credits but okay
what
??
the code on this is very complicated bc its a module script and the way i learned modulescripts is fucked af
i mean this
you usaually don't need multiple places for a single thing
you can just do like story mode
not story mode multiplayer
why only story mode?
no reason to do multiplayer or singleplayer just send data when you join it
you don't have to use multiple places
you can if you want
you could make a place for every chapter
or stuf
wdym
can you add me too the game?
on studio its BlueNerfx
i need to add you as a friend
i did
o/
?
add me to the game lol
sorry
you must be my friend so i can add you to the game
oh ok
why is it in so many scripts 😭
oh wtf
this is cursed lmaoo
i think this is the worst lobby system ive ever seen like not in a disrespectful way but like this is crazy
@astral cave can you explain WHAT im meant to press 😭
no generally i thought i was missing something, nope 😭
im fixing this for my own safety 🙏
making a create lobby menu
?
so you can customize settings like if its public, max players, etc
and the main menu?
i just hid it while i was making this
what for
.
no
you will click host
then it will show this
then you click create
then it has a code
and then you wait for your friends to join, and once they do
you can start
so a new host screen
yes
the lobby is an 1 player game
oh WHAT
do not set ur games as one player
why
roblox's algorithm hides them more
just set it to like 15 it doesn't really matter anyway
also your thing to join story mode multy player isn't working
so what happens:
Player 1 (host) joins game -> friends join them (host) -> Player 1 clicks host -> sets as private (or public if they want) -> if its public then friends can just choose from a list of public games, but randoms might accidently join. if it's private, they input the code on the players screen. -> they join the lobby -> once all friends joined -> host starts game.
i know how that works
ye
ok but can you do it so friends can still join with the code if the game alredy startet?
so the script wasn't for nothing
i can... but thats alot of work, and that seems like cheating can happen and stuff.
im happy to do it tommorow but there isn't really a good reason for people to join once the games started
wdym cheating?
like one player gets to the end
second player join and beat game
second player +1 win
second player rejoin first again
then don't give the secound player the win
were is the back button?
yes
** You are now Level 9! **
@grave badger
arent the teleport scripts suposed to be local?
uh
i think you can do them both
i'll see later im tired af
its 1am
lol
yea ok
Elmo arent humans suposed to sleep then?
itss fineee
yeaaa
@grave badger can you make it 6 players?
ok
actually
the guis will be too small
i can
just tmr
ok
@astral cave
you there?
what game is the thing in?
is it in storymode multy player?
?
story mode has single and multyplayer
im going to bed
** You are now Level 8! **
k