Attempt to concatenate string with nil With JobID

Okay i have a script that turns a table into a string for messagingservice but the jobid is nil even though the script prints it

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()
		local publishSuccess, publishResult = pcall(function()
			local playercount = #game.Players:GetChildren()
			local ownername = game.ReplicatedStorage.MsgserviceInfo.Owner.Value
			local mapname = game.ReplicatedStorage.MsgserviceInfo.Map.Value
			local JobID = game.ReplicatedStorage.MsgserviceInfo:WaitForChild("JobID").Value
			print(JobID)
			local info = {
				playercount ,
				JobID,
				ownername,
				mapname
			}
			local stringMessage = info.playercount.." "..JobID.." "..info.ownername.." "..info.mapname -- THIS IS LINE 19
			MessagingService:PublishAsync(MESASSGING_TOPIC, stringMessage)
		end)
		if not publishSuccess then
			print(publishResult)
		end
	end)
end)

Result:
image

is playercount, ownername, or mapname nil?

1 Like

no they all work fine its only when i try sending over the job id

try tostring(JobID), it might not be a string or something, other than this, I’m not sure

You can concatenate strings with numbers so this isn’t it.

Does the print(jobID) print the correct value?

yes they do thirty-characters

It’s everything except jobID that’s nil.

The reason is your trying to access keys that don’t exist. It’s an array, not a dictionary. Arrays only have indexes.

Edit: For what your trying to do to work, you need to assign the values keys.

local info = {
			["playercount"] = playercount ,

And so on …

Lemme know if that helped.