When I try to send a table with Messaging Service
, the server returns me with this error:
The error happens into the lobby side of the game, the message is sent from another place which is the main game
This is the script for the main game
local dataStore = game:GetService("DataStoreService")
local messagingService = game:GetService("MessagingService")
local httpService = game:GetService("HttpService")
local ownerFound = false
local JobId = game.JobId
local owner
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
if ownerFound == false then
ownerFound = true
local LobbyData = {
LobbyName = player.Name .. "'s Lobby",
LobbyJobId = JobId,
LobbyOwner = player.Name
}
--local encodedData = httpService:JSONEncode(LobbyData)
messagingService:PublishAsync("GlobalAnnouncement", LobbyData)
print(encodedData)
print("Sent")
end
end)
end)
and this is the script for the Lobby Side
function callbackFunction(serviceData)
local decodedData = httpService:JSONDecode(serviceData.data)
print("Decoded Data")
local newLobby = Instance.new("StringValue", TeamsFolder)
newLobby.Name = decodedData.LobbyName
local owner = Instance.new("IntValue", newLobby)
owner.Name = "Owner"
owner.Value = decodedData.Owner
local LobbyJobId = Instance.new("IntValue", newLobby)
LobbyJobId.Name = "GameJobId"
LobbyJobId.Value = decodedData.LobbyJobId
end
realmile
(mile)
July 23, 2021, 11:44am
#2
In the first script you are not encoding the data, in the second one you are decoding serviceData.data, you should change that to only serviceData.
now it returns me with this error, If Im not mistaken the data that is gonna be sent trough messaging service will return a JSON format which I do not know how to convert
realmile
(mile)
July 23, 2021, 11:56am
#4
Are you encoding the data and sending that or are you sending raw data?
I think by publishing the message, the service will automatically encode the data
(from what I read about)
realmile
(mile)
July 23, 2021, 12:06pm
#6
Are you using SubscribeAsync to receive data?
Also im not sure if you were using this but here this might help:
Introduction
Recently Roblox released a new service called MessagingService , this allows for you to easily communicate between all of your running servers. How is this useful? Users can do so many things now that before were extremely complex and typically required an external webhost/database, things like custom matchmaking and crossover chats.
In this tutorial I will be teaching you how to use MessagingService to create a crossover chat. I will be releasing a tutorial in the near future abou…
1 Like
Yes I also used that lol thats were I found some info about sending tables into messaging service and yes I forgot to paste the part where I use Subscribe Async lol
Also its fixed now tnx for the help
(also the solution was doing this:
local decodedData = httpService:JSONDecode(ServiceData.Data)
I didnt captitalize d Into Data llol
2 Likes