You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I want to send data to a server with my lobby system. I am using MessagingService (which is not the problem, on both ends the correct values are sent) -
What is the issue? Include screenshots / videos if possible!
The PrivateServerID returned by the ReserveServer is different from the actual server’s PrivateServerID. Which means they don’t match which means the lobby server never sends data over to the game server which means it’s all left empty. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
There’s NOTHING on DevForum about my problem. Making a Topic is my last resort as I don’t know what to do.
The important code is here:
The lobby server
if action == "start" then
if lobbyobj.Host.Value == player and lobbyobj.Privacy.Value ~= "Teleporting" then
game.Debris:AddItem(lobbyobj,10)
lobbyobj.Privacy.Value = "Teleporting"
local reserve,privateID = game["Teleport Service"]:ReserveServer(18541756425)
print(reserve)
print(privateID)
local teleportedplayers = {}
local playerobjects = lobbyobj.Players:GetChildren()
for i = 1,#playerobjects do
table.insert(teleportedplayers,playerobjects[i].Value)
task.spawn(function()
game.ReplicatedStorage.MiniNotification:FireClient(playerobjects[i].Value,Color3.new(1,1,1),"Teleporting...")
game.ReplicatedStorage.SublevelChangeScreen:FireClient(playerobjects[i].Value,lobbyobj.Host.Value.Name.."'s Lobby")
end)
end
local thehost = lobbyobj.Host.Value.UserId
local lobbyname = lobbyobj.Name
local event = script.GetAndSendData.Get.Event:Connect(function(payload)
print(payload)
local data = game:GetService("HttpService"):JSONDecode(payload)
print("Servers got data")
if data["ID"] == privateID and data["Type"] == "request" then
print("data is a request from teleported server")
local sentdata = {
["ID"] = privateID,
["Type"] = "data",
["Name"] = lobbyname,
["Host"] = thehost
}
local sentpayload = game:GetService("HttpService"):JSONEncode(sentdata)
print(sentpayload)
script.GetAndSendData.Send:Fire(sentpayload)
print("sent requested data")
print(data)
end
end)
for i = 1,20 do
game["Teleport Service"]:TeleportToPrivateServer(18541756425,reserve,teleportedplayers)
wait(1)
end
event:Disconnect()
else
game.ReplicatedStorage.MiniNotification:FireClient(player,Color3.new(1,0,0),"You are not the host!")
end
end
The game server
wait(1)
local messagingservice = game:GetService("MessagingService")
local privateID = game.PrivateServerId
messagingservice:SubscribeAsync("Servers",function(payload)
print(payload)
local data = game:GetService("HttpService"):JSONDecode(payload)
print("got data!")
print(privateID)
if data["ID"] == privateID and data["Type"] == "data" then
print("got requested server data.")
game.ServerStorage.Storage.SecretServerData.Host.Value = data["Host"]
game.ServerStorage.Storage.SecretServerData.LobbyName.Value = data["Name"]
game.ServerStorage.Storage.SecretServerData.HostName.Value = game.Players:GetNameFromUserIdAsync(data["Host"])
end
end)
local payload = {
["ID"] = privateID,
["Type"] = "request"
}
local sentpayload = game:GetService("HttpService"):JSONEncode(payload)
print(sentpayload)
messagingservice:PublishAsync("Servers",sentpayload)
Is there something I am missing? It doesn’t matter if the lobby server is left empty or not, I’ve tested it by leaving my alt account in the lobby server and it doesnt change anything