Messaging service subscribe async not working

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Get the reserve server code from the reserved server itself

  2. What is the issue? Issue marked in script, subscribe not firing (even though the other subscribe events are)

  3. What solutions have you tried so far? Actually, hours of research of how to do this. Found nothing that fits my code.
    –NO ERRORS RETURNED ON BOTH SERVERS–
    Reserved server

--Join game-- 

local MessagingService = game:GetService("MessagingService")


local MESSAGING_TOPIC = "Reserve"
local MESSAGING_TOPIC2 = "Reservecode"
function sub()

	local publishSuccess, publishResult = pcall(function()
	print('hey')
		MessagingService:PublishAsync(MESSAGING_TOPIC, {id = game.PrivateServerId})
	end)
	if not publishSuccess then
		warn(publishResult)
	end

	local subscribeSuccess, subscribeConnection = pcall(function()
	--NOT FIRING
	return MessagingService:SubscribeAsync(MESSAGING_TOPIC2, function(message)
			print('hi')

			if message.Data.id == game.PrivateServerId then
				game.ServerStorage.ReserveCode.Value = message.Data.code
				
			end
		end)
	end)
	if not subscribeSuccess then
		print('err')
		wait(1)
		sub()
	end
end

sub()





Normal server

game.ServerStorage.reserve.Event:Connect(function(code, id)
	--Join game-- 
	print('.')
	print(code)
	print(id)
	print('.')
	local MessagingService = game:GetService("MessagingService")


	local MESSAGING_TOPIC = "Reserve"
	local MESSAGING_TOPIC2 = "Reservecode"
	local function sub()

		-- Subscribe to the topic

		local subscribeSuccess, subscribeConnection = pcall(function()
			return MessagingService:SubscribeAsync(MESSAGING_TOPIC, function(message)
			print('mail')
				print(message.Data.id)
				print(id)
				if message.Data.id == id then
print('match')

					local publishSuccess, publishResult = pcall(function()

						MessagingService:PublishAsync(MESSAGING_TOPIC2, {id = id, code = code})
					end)
					warn(publishResult)
				end
			end)
		end)
		if not subscribeSuccess then
			wait(1)
			sub()
		end
	end

	sub()





end)

Output:

Normal
image

Reserved
image

Its late for me, sry if i forgot some info.
also works 10% of the time

Also, please tell me if there is a better way to get the id

game:GetPrivateServerId does not work by the way.

image

Did you try testing out outside studio? Because I’m sure it doesn’t work in-studio.