#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)

astral cave
#

i tryied to make a system that makes an private server no one can join exepct with an code that worked and all but i can't get the code to work from the different game place so people can join

dapper scarab
#

assuming this is from no scripting experience its gonna do something like this

dapper scarab
#

writing the code rq

#

this is taking a bit

astral cave
dapper scarab
#

so, what is your issue

astral cave
#

i have this

dapper scarab
#

so what happens when the remote is fired

astral cave
astral cave
dapper scarab
#

you used chatgpt to generate this, right?

#

(just wondering)

astral cave
#

no the roblox ai

dapper scarab
#

oh

patent windBOT
#

studio** You are now Level 4! **studio

dapper scarab
#

okay so your second script PlayerCountAndCodeGui

dapper scarab
#

oh wait maybe

#

is your RequestJoinCode remote being used anywhere?

#

do you have more scripts

astral cave
#

no

dapper scarab
#

okay so where are you saving the join codes

astral cave
#

well yes but for other things

astral cave
#

or do you mean were i can see the code in game?

dapper scarab
#

no im just wondering so

#

you createdthe server

#

and presumably you saved the join code somewhere, right?

astral cave
#

yes i think

dapper scarab
#

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

dapper scarab
#

basically

#

how does your game handle teleporting

#

is it

astral cave
#

i can send a video how its supposed to go along if that helps

dapper scarab
#

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

astral cave
#

ok 1 sec

dapper scarab
#

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

astral cave
#

i don't realy know

dapper scarab
#

okay then

#

wheres the script that makes the code?

astral cave
#

i think thats it

dapper scarab
#

no so

#

the code generator should be in the other place

astral cave
#

wait no

#

that were the generation is

#

in the game were its supposed to teleport you

dapper scarab
#

yeah

astral cave
#

was that right?

dapper scarab
#

yes

#

i just need to see the code to see if it saves anywhere

astral cave
#

ok the code is in the exact same game

dapper scarab
#

oh

astral cave
#

?

dapper scarab
#

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

astral cave
#

i told the ai to make it in that script

dapper scarab
#

i see

#

but

#

there should be a script in serverscriptservice

#

that actually generates the join code

#

is there one there

astral cave
#

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

dapper scarab
#

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

astral cave
#

whats the problem?

dapper scarab
#

oh actually wait

#

is this script in the hosting game or the lobby game

astral cave
#

hosting game

#

should it be in the lobby game?

dapper scarab
#

no it shouldn't

astral cave
#

ok

dapper scarab
#

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!

astral cave
#

btw the code manager is in the serverscriptservice is that right?

dapper scarab
#

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

astral cave
#

so

#

i still don't know

dapper scarab
#

k so

#

this level of scripting is a bit complicated for just the ai assistant to handle

astral cave
#

please explain it to me in monkey terms so i can understand

dapper scarab
#

okay

#

when player teleports they teleport to other side of the forest

astral cave
#

oooh

dapper scarab
#

theres person there who give piece of paper

#

with the code on it

#

but telephone hasnt been invented yet

astral cave
#

ok

#

why?

dapper scarab
#

because erm

#

theres no code to do it

astral cave
#

ok

#

the lobby is an single player game btw

dapper scarab
#

yes

patent windBOT
#

studio** You are now Level 5! **studio

astral cave
#

does that hinder anything to the code?

dapper scarab
#

uh not really

astral cave
#

ok

dapper scarab
#

well, from what i understand the ai assistant didnt really help with anything

astral cave
dapper scarab
#

if you want you can add me into team create and i can try to fix the join system

astral cave
#

yes please

dapper scarab
#

ok

#

whats your username

astral cave
#

fire_fox98395

dapper scarab
#

ok i sent a friend request

#

i'm MarcusG4M3R

astral cave
#

added

#

and added in to the game

dapper scarab
#

okay

astral cave
#

and as a thanks i will give you mod rolle with credits if the game comes out some time

dapper scarab
#

nah you dont have to

astral cave
#

i insist on it

#

so please take it as a thank you

dapper scarab
#

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

astral cave
#

?

dapper scarab
#

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
astral cave
#

so it could teleport me but it can't cuz of the key

dapper scarab
#

no basically

#

you have the super long code

grave badger
#

i can make a module if ya want

#

for a lobby system

astral cave
dapper scarab
#

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

astral cave
#

ok

astral cave
grave badger
grave badger
#

you would have a module in replicated storage named like LobbySystem

astral cave
#

ok

grave badger
grave badger
#

but it just makes stuff easier for you

astral cave
dapper scarab
#

modulescripts make beginner's life extremely easier

#

instead of getting chatgpt to write like 50 scripts you just do smt like
CodeManager:TeleportToCodePlace("R93KS")

astral cave
grave badger
#

clean and simple so you can do like module:createlobby(lobby settings)

module:.oinlobby(code)

module:listpubliclobbies() etc

astral cave
#

ok

grave badger
#

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

dapper scarab
#

ohh my god 😭

astral cave
patent windBOT
#

studio** You are now Level 8! **studio

astral cave
dapper scarab
#

maybe

grave badger
astral cave
grave badger
astral cave
dapper scarab
#

ok i guess that works

#

its not the most efficient but it works

grave badger
#

im thinking of making a thing with the chatgpt api that just basically makes devs lifes 10x easier

astral cave
grave badger
astral cave
grave badger
#

its a plugin ima make

astral cave
#

but just a differeent one?

dapper scarab
#

@astral cave i think its done

astral cave
#

ok ima test it

dapper scarab
#

if it doesnt work press F9 and go to server and see if anythings there

astral cave
#

ok

#

it gives me an error

dapper scarab
#

whats the error

astral cave
#

idk it was empty

dapper scarab
#

OH

#

i found the issue

astral cave
#

what was it?

dapper scarab
#

fixed

#

i forgot half the ocod

#

code

astral cave
#

wdym you forgot?

dapper scarab
#

went to write something else then forgot

astral cave
#

oh ok

dapper scarab
#

try now

#

does it work?

astral cave
#

idk i lost connection

#

no it doesn't

dapper scarab
#

i deleted the code that checks if its valid

#

isnt neccessary

#

try going into the game my code is PH60T4

astral cave
#

what isnt neccessary

#

ok wait

#

i can't join

dapper scarab
#

what error

astral cave
#

no wait i joined

#

but the wrong server

dapper scarab
#

whattt

astral cave
#

or did you leave?

dapper scarab
#

no i didnt leave

astral cave
#

ok

dapper scarab
#

hang on

astral cave
#

k

dapper scarab
#

you teleported?

astral cave
#

yes

#

but diferent server

dapper scarab
#

ok

#

fixed i think

#

try joining SRM4EU

astral cave
#

did you upd the game?

#

nope couldn't join

dapper scarab
#

at all?

#

how about this

astral cave
#

yes

dapper scarab
#

you host a lobby

#

tgell me the code

astral cave
#

ok

#

L6AKD9

grave badger
#

back

astral cave
#

hi

astral cave
dapper scarab
#

let me ese

astral cave
#

?

dapper scarab
#

server cant be found for some reason

#

let me add more debugging statements

astral cave
#

ok

dapper scarab
#

ohh

#

i know whats happening

#

each person gets a unique code

#

that shouldn't happen

astral cave
#

how is that possible?

dapper scarab
#

i dont know

#

try making a new server

#

wait

#

no

#

ill make it

#

try joining 9K5YM0

astral cave
#

you mean a naw game?

dapper scarab
#

no uh

#

rejoin and try to join 9K5YM0

astral cave
#

oh ok

dapper scarab
#

if it doesnt work press F9 and go to server

#

tell me anything thats there

#

like this

astral cave
dapper scarab
#

my server detected the message to get the code

#

but your server didnt detect the message back

#

erm

astral cave
#

uhauawshdawwsduhsaadws

#

what

midnight belfry
#

whats the current problem

#

i cba to read all 300 messages

astral cave
#

idk

midnight belfry
#

show code

dapper scarab
#

oh i know whats happening!

astral cave
dapper scarab
#

fixed it

#

yeah just rejoin the lobby place and try joining again

dapper scarab
midnight belfry
#

peak

astral cave
dapper scarab
#

oh wait

patent windBOT
#

studio** You are now Level 6! **studio

dapper scarab
#

ur gonna have to rejoin one more time

#

9K5YM0

astral cave
#

it worked

#

@dapper scarab

dapper scarab
#

YES

#

does the code appear the same for you

#

like is it different or the same

astral cave
#

tysm for the help

dapper scarab
#

no problem

#

lmk if you need any more help with this

astral cave
#

ok

dapper scarab
#

add solved tag i guess

astral cave
#

ok

#

@dapper scarab is that good?

grave badger
#

ok done @astral cave

#

this will be super simple for you

dapper scarab
grave badger
#

script:

#

@astral cave lemme know what you think

astral cave
#

uuuuuh

#

wait

#

do i have to make that in every game?

grave badger
#

??

#

the code on this is very complicated bc its a module script and the way i learned modulescripts is fucked af

astral cave
grave badger
#

you can just do like story mode

#

not story mode multiplayer

astral cave
#

why only story mode?

grave badger
#

no reason to do multiplayer or singleplayer just send data when you join it

grave badger
#

you can if you want

#

you could make a place for every chapter

#

or stuf

astral cave
grave badger
#

can you add me too the game?

astral cave
#

whats your roblox name?

grave badger
astral cave
grave badger
#

js logged on in my browser

#

add me

astral cave
grave badger
#

o/

astral cave
#

?

grave badger
#

add me to the game lol

astral cave
grave badger
#

sorry

astral cave
#

you must be my friend so i can add you to the game

grave badger
#

yeah

#

i added

#

my internets really laggy

#

my messages werent' gooing throug

#

h

astral cave
#

oh ok

grave badger
#

why is it in so many scripts 😭

astral cave
#

idk

#

i didn't make it

#

the ai and switch made it

grave badger
#

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 😭

grave badger
#

no generally i thought i was missing something, nope 😭

#

im fixing this for my own safety 🙏

astral cave
#

dude

#

what are you doing

#

@grave badger

grave badger
#

making a create lobby menu

astral cave
#

?

grave badger
#

so you can customize settings like if its public, max players, etc

astral cave
#

and the main menu?

grave badger
astral cave
#

yea i know

#

but what is that for?

#

@grave badger

grave badger
astral cave
#

that what your making rn

#

is that the new start screen?

grave badger
grave badger
#

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

astral cave
#

so a new host screen

grave badger
#

yes

astral cave
#

the lobby is an 1 player game

grave badger
#

do not set ur games as one player

astral cave
#

why

grave badger
#

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

astral cave
#

it worked for me like 5 min ago

#

i mean if thats better ok but please tell me first

grave badger
#

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.

grave badger
#

ye

astral cave
#

so the script wasn't for nothing

grave badger
#

im happy to do it tommorow but there isn't really a good reason for people to join once the games started

grave badger
#

like one player gets to the end

#

second player join and beat game

#

second player +1 win

#

second player rejoin first again

astral cave
grave badger
#

ok

#

sure i'll do it tommorow its kinda late

astral cave
#

yea ok

#

but il let the other join game for now

#

@grave badger

grave badger
#

what

#

ok

astral cave
#

were is the back button?

grave badger
#

hello

#

@astral cave are you there

astral cave
#

yes

patent windBOT
#

studio** You are now Level 9! **studio

astral cave
#

@grave badger

grave badger
#

ok

#

thanks just checking

astral cave
grave badger
#

i think you can do them both

#

i'll see later im tired af

#

its 1am

#

lol

astral cave
#

yea ok

astral cave
grave badger
#

itss fineee

astral cave
#

yeaaa

astral cave
#

@grave badger can you make it 6 players?

grave badger
#

actually

#

the guis will be too small

#

i can

#

just tmr

astral cave
#

ok

grave badger
#

@astral cave

#

you there?

#

what game is the thing in?

#

is it in storymode multy player?

astral cave
#

story mode has single and multyplayer

grave badger
#

im going to bed

patent windBOT
#

studio** You are now Level 8! **studio

astral cave