I am developing a lobby system, and the whole concept of it is tat you are able to reserve servers as “rooms”, with the option to make it public (so the game shows up on server listings) or private(doesn’t show up on game listings, requires a password). In these games the host recieves a password which can be shared to anyone who wants to join. However, I am having trouble recieving key information from the server in time for the player handling to start.
Let me clarify this in more detail:
When I create the game in the lobby server it successfully publishes without any errors, and with the correct information, which makes me think that there is an obvious issue when it comes to me subscribing to the topic.
I have checked that the topics are the same and there are no errors, however on join it either kicks you or it just doesn’t prompt you, which isn’t what I want
CODE
Publishing End:
--PUBLISHING END--
local sendingTable ={
Password = "NA",
AccessCode = serverCode,
Difficulty = DataTable.Difficulty,
Host = Player.UserId
}
local stringMessage = sendingTable.Host.." "..sendingTable.Password.." "..sendingTable.Difficulty.." "..sendingTable.AccessCode
print(stringMessage)
local publishSuccess, publishResult = pcall(function()
MessagingService:PublishAsync(MessagingTopic, stringMessage)
end)
if publishSuccess then
print("Sent The Following Password To Server Access Code: "..sendingTable.AccessCode..": "..sendingTable.Password)
Recieving End
---RECIEVING ENG--
local Topic = "PASSWORD_SENDING"
local Host,Password
local isPrivate = false
local AccessCode
local String
local MessagingService = game:GetService("MessagingService")
local subscribeSuccess, subscribeConnection = pcall(function()
return MessagingService:SubscribeAsync(Topic, function(message)
String = message.Data
local Table = string.split(String, " ")
game.ReplicatedStorage.Difficulty.Value = Table[3]
Password = Table[2]
Host = Table[1]
AccessCode =Table[4]
print(Host, Password , Table.Difficulty)
if Password == "NA" then
isPrivate = false
else
isPrivate = true
end
end)
end)
if subscribeSuccess then
subscribeConnection:Disconnect()
game.Players.PlayerAdded:Connect(function(Player)
if Host ~= nil then
if Player.UserId == Host then
game.ReplicatedStorage.promptStartScreen:FireClient(Player,Password, isPrivate)
else
if isPrivate then
game.ReplicatedStorage.promptPasscode:FireClient(Player)
else
game.ReplicatedStorage.waitingEvent:FireClient(Player)
end
end
else
for index, Player in pairs(game.Players:GetPlayers()) do
Player:Kick("Message sent from remote server failed. Please try again.")
end
end
end)
else
for index, Player in pairs(game.Players:GetPlayers()) do
Player:Kick("Error on the server side. Removing players.")
end
end
game.ReplicatedStorage.promptStartScreen.OnServerEvent:Connect(function()
game.ReplicatedStorage.isReady.Value = true
game.ReplicatedStorage.startGame:FireAllClients()
end)
game.ReplicatedStorage.promptPasscode.OnServerEvent:Connect(function(Player, Code)
if string.upper(Code) == string.upper(Password) then
game.ReplicatedStorage.loginSuccessful:FireClient(Player)
else
Player:Kick("Failed to login.")
end
end)
Help/?