Second Variable in messaging service is always nil

i have a cross server messaging script but when i send the message the 2nd variable is nil

First code:

local MessagingService = game:GetService("MessagingService")
local Players = game:GetService("Players")

local MESSAGING_TOPIC = "ReceiveServerInfo"
local MESSAGING_TOPIC2 = "RequestServerInfo"

game.Players.PlayerAdded:Connect(function(player)
	local subscribeSuccess, subscribeConnection = pcall(function()
		return MessagingService:SubscribeAsync(MESSAGING_TOPIC,function(plrcount, jobid, owner)
			local serverui = game.ReplicatedStorage.UI.Server:Clone()
			serverui.Parent = player.PlayerGui.SBrowser
			serverui.PlayerCount.Text = (plrcount.Data.."/125")
			serverui.Owner.Text = (owner.Data.."👑")
			serverui.JOINID.Value = jobid.Data
		end)
	end)
	if subscribeSuccess then
		player.AncestryChanged:Connect(function()
			subscribeConnection:Disconnect()
		end)
	end
end)

Second Code:

local MessagingService = game:GetService("MessagingService")

local MESASSGING_TOPIC = "ReceiveServerInfo"
local MESSAGING_TOPIC2 = "RequestServerInfo"

local subscribeSuccess, subscribeConnection = pcall(function()
	return MessagingService:SubscribeAsync(MESSAGING_TOPIC2, function(plrcount)
		local publishSuccess, publishResult = pcall(function()
			local plrcount = #game.Players:GetPlayers()
			local jobid = game.JobId
			local owner = game.ReplicatedStorage.MsgserviceInfo.Owner.Value
			MessagingService:PublishAsync(MESASSGING_TOPIC, plrcount, jobid, owner)
		end)
		if not publishSuccess then
			print(publishResult)
		end
	end)
end)

On the first script it always errors at line serverui.Owner.Text = (owner.Data.."👑")

Can emojis even be used in scripts like that? Because that seems like it could be an issue. If you’ve used emojis in scripts before, however, and it worked, I got nothing else.

emoji or no emoji it still errors.

MessagingService arguments are a bit funny. Basically it works like this:

MessagingService:PublishAsync(string topic, Variant data)
MessagingService:SubscribeAsync(string topic, function(Dictionary d)
    local data = d.Data -- data is equal to the parameter in PublishAsync()
    local sent = d.Sent -- timestamp, basically tick()
end)

In order to send multiple arguments, data will have to be a table or dictionary. I would suggest using a dictionary because it stores a key-value pair

2 Likes