Help with messaging service

I am trying to make a script that sends a message back to the main servers but it is not working. I have no idea what the problem is. I get this error: endfefefe

local messagingService = game:GetService("MessagingService")
if game.VIPServerOwnerId ~= 0 then
	--VIP SERVER
elseif game.VIPServerId ~= "" then
	--Reserved server
	wait(1)
	if game.ServerStorage.ServerCode.Value == "AQ17" then
		messagingService:SubscribeAsync("ServerCode", function(message)
			print("Worked")
			game.ServerStorage.ServerCode.Value = message.Data
			wait(1)
			messagingService:PublishAsync("ServerAmount", #game:GetService("Players"):GetPlayers())
			messagingService:PublishAsync("ServerCode", game.ServerStorage.ServerCode.Value)
		end)
	end
	wait()
   print(game.ServerStorage.ServerCode.Value)
end


Try to type
print(message.Data)
i think you will find it nil
because ServerCode is not published yet or you dont have any other running servers
Messaging Service is hard to test it in Roblox Studio

I have been testing it in a game with 2 accounts and I think I fixed it but now I have another problem. I am trying to see if a value if = to something. Here is the code I have:
if game.ServerStorage.ServerCode.Value == “FFFF” then
messagingService:SubscribeAsync(“ServerCode”,function(message)
print(“Working Test”)
–game.ServerStorage.ServerCode.Value = message.Data
wait(1)
messagingService:PublishAsync(“ServerAmount”, #game:GetService(“Players”):GetPlayers())
messagingService:PublishAsync(“ServerCode”, game.ServerStorage.ServerCode.Value)
end)
end

So what is the problem in that script

It is not running the function but the value is = to FFFF

try to add
print(game.ServerStorage.ServerCode.Value)
under
if game.ServerStorage.ServerCode.Value==“FFFF” then

if it printed then the problem from the Messaging Service not from the ServerCode
if doesn’t add “else” to the end to check what is the value and why the function is not running

It just does not run anything meaning that it is false but I can show you what the message is:
local code = math.random(0, 1000000)
MessagingService:PublishAsync(“ServerCode”,code)

If the code is a number so why you compare it with “FFFF” (string) and why you use random
try to use Job Id

How can I use it? _____________________________________________________________________________________

the Job Id is a string consists of a mixture of numbers, letters and commas, exemple:
"24f7c45b-29cc-4a7f-81d1-c3b28fee1089"
Each server in Roblox has its own Job Id and is different from other servers.
you can get it by do game.JobId
Capture
I have it 0 because im in studio
So your code should be like this:
if game.JobId == “Any Job id you want” then
--your code
end
Read this: