Custom radio using MessagingService is producing error for no reason?

Hello again. Today I was trying to mess around with the new MessagingService API, and I was trying to implement this API into my radio, to make a cross-server radio channel. I started by using Kurookku’s shout system that used this API, and I would use this code to make the radio channel. But then I ran across an issue. The developer console is outputting the error “Message Router Service disconnected.”, and this refered to line 11 of a script in Server Script Service.

The problem is that there is nothing on that line, so I honestly don’t know what to do at this point.
I’ve tried re-doing the whole thing based off of the shout system, but it still makes the exact some error. Any help with this would be greatly appreciated!

LocalScript (Not causing the error for all I know, but I honestly don’t know.)

local plr = game.Players.LocalPlayer
local ShoutEvent = game:GetService("ReplicatedStorage"):WaitForChild("General_Events"):WaitForChild('ShoutEvent')
local Channels = require(game.ReplicatedStorage.Channels)

ShoutEvent.OnClientEvent:Connect(function(channel,data)
	local rank
	local role
	print("CrossServer Script detected correctly: 2")
	local p = game.Players:GetUserIdFromNameAsync(data.Sender)
	if p.TeamColor == BrickColor.new("Gold") then
		rank = "AST"
		role = p:GetRoleInGroup(1234)
	elseif p.TeamColor == BrickColor.new("Medium stone grey") then
		rank = "DOC"
		role = p:GetRoleInGroup(1234)
	elseif p.TeamColor == BrickColor.new("Really red") then
		rank = "CFD"
		role = p:GetRoleInGroup(1234)
	elseif p.TeamColor == BrickColor.new("Lapis") then
		rank = "CPD"
		role = p:GetRoleInGroup(1234)
	elseif p.TeamColor == BrickColor.new("Black") then
		rank = "SWAT"
		role = p:GetRoleInGroup(1234)
	end
	local frame = game.ReplicatedStorage:WaitForChild("GUI"):WaitForChild("ChatFrame"):Clone()
	frame:WaitForChild("Message").Text = p.Name.." ("..rank..", "..role..")"..": "..data.Message
	frame.Parent = game.Players.PlayerGui.ToolScreens.Radio.Wrapper:WaitForChild(channel)
end)

local ChannelsList = {}
local CurrentChannel = 1

for i,v in next,Channels do
	if v then
		ChannelsList[#ChannelsList+1] = i
	end
end

if #ChannelsList < 1 then return end--Make sure the code below wont do anything if there is no channel

plr.Chatted:Connect(function(msg)
	if plr:WaitForChild("Settings"):WaitForChild("talkingRadio").Value == true then
		if plr:WaitForChild("PlayerGui").ToolScreens.Radio.Wrapper.Settings.CurrentFrame.Value == "CrossServer" then
			print("CrossServer Script detected correctly: 1")
			ShoutEvent:FireServer(ChannelsList[CurrentChannel],msg)
		end
	end
end)

Server Script (Notice that there is nothing on line 11)

local InStudio = game:GetService('RunService'):IsStudio()
local MessagingService = game:GetService('MessagingService')

local Channels = require(game.ReplicatedStorage.Channels)
local ShoutEvent = game.ReplicatedStorage.General_Events.ShoutEvent

local chatService = game:GetService("Chat")
local replicatedStorage = game:GetService("ReplicatedStorage")

local Chat = game:GetService('Chat')

local Filter = Chat.FilterStringForBroadcast

for Channel,Active in next,Channels do
	if InStudio then break end
	if Active then
		MessagingService:SubscribeAsync(Channel,function(returnedData)
			ShoutEvent:FireAllClients(Channel,returnedData.Data)
		end)
	end
end

local Cooldown = {}

ShoutEvent.OnServerEvent:Connect(function(plr,channel,message)
	print("CrossServer Script detected correctly: 5")
	if InStudio then return end
	Cooldown[plr.Name] = Cooldown[plr.Name] or 0
	if Channels[channel] and message and Cooldown[plr.Name] < 2 the
		Cooldown[plr.Name] = Cooldown[plr.Name] + 1
		local Works,FilteredMessage = pcall(Filter,Chat,message,plr)
		if Works then
			MessagingService:PublishAsync(channel,{
				Sender = plr.Name;
				Message = FilteredMessage;
			})
			wait(30)
			if Cooldown[plr.Name] then
				Cooldown[plr.Name] = Cooldown[plr.Name] - 1
			end
		else
			Cooldown[plr.Name] = Cooldown[plr.Name] - 1
		end
	end
end)

game.Players.PlayerRemoving:Connect(function(plr)
	Cooldown[plr.Name] = nil
end)

All of the print statements that are in there don’t even print except for the first.

1 Like

The reason why this is happening is that you’re not in the beta program.

You can enroll here.

1 Like

This can also be because if you’re using a group game, and the owner of the group isn’t in the beta program, it won’t work. This happened to me before.

The MessagingService is an exclusive program reserved for only members of the Beta program. Like @Rawblocky said, you need to be enrolled to use the messaging service or it will deny all access to the service