Global Modcall Notification

Hello, I made a modcall system, but I still didn’t finish one thing.
So that thing is a global notification, that’s the thing I don’t know how to send mod call notification to every active server!

You could try using a Messaging Service listener to listen for the modcall. When you run the modcall script, just use the PublishAsync() method of Messaging Service and add in a SubscribeAsync() listener to receive the signal. There’s a tutorial on using the Messaging Service here : Messaging Service

Oh, this function is already added?
I didn’t knew. :sweat_smile:

This can be achieved using MessageService, the newly implemented service.

--In a server script
local Announcement = game:GetService("ReplicatedStorage").AnnouncementRemote
Announcement.OnServerEvent:connect(function(player,message) --Detecting when player types announcement.
    if player.Name == "DRCGaming" then --Check the player's name in case if they were an exploiter
        game:GetService("MessagingService"):PublishAsync("Announcement","Hello all!") --Send the message
    end
end)

--In another server script (or in the same one)
game:GetService("MessagingService"):SubscribeAsync("Announcement",function(message) --Note "message" is a string, and when creating the text display, make sure to set the text to message and not "message"
    --Your message code here
end)

--In a local script

TextBox.FocusLost:connect(function(enter)
    if enter then --Checking if the player pressed enter to close the textbox
        game:GetService("ReplicatedStorage").AnnouncementRemote:FireServer(Textbox.Text)
    end
end)

Hope this helps :slight_smile:

1 Like

I have a problem: Currently MessagingService doesn’t work in Studio.

image

This is a known limitation of the MessagingService and the only main workaround is to upload the game to Roblox. Since it is a network call, you will want to use a pcall so a call erroring doesn’t halt the game.

1 Like

Hmmm, thanks for reply. I’ll try this!

Uhhh, i have a problem.

event.OnServerEvent:Connect(function(plr)
	game:GetService("MessagingService"):PublishAsync("LiveModcall", "ModcallTicket")
end)

game:GetService("MessagingService"):SubscribeAsync("LiveModcall", function(reason, sender)
	for _,v in pairs(game.Players:GetPlayers()) do
		if v.IsMod.Value == true then
			if v.PlayerGui:FindFirstChild("ModcallNotify") then
				local gui = v.PlayerGui:FindFirstChild("ModcallNotify")
				gui.Frame.Visible = true
				print(reason)
				print(sender)
				gui.Frame.Reason.Text = reason
				gui.Frame.Username.Text = sender.Name
				gui.Frame.PlayerImage.Image = image_format1..sender.UserId..image_format2
				gui.Frame.UserId.Text = sender.UserId
				gui.ModTicket.PopOut:FireClient(v)
			end
		end
	end
end)

EDIT:
–Local script

local plr = game:GetService("Players").LocalPlayer

event_2:FireServer(panel.InputBox.Input.Text, plr)
event.OnServerEvent:Connect(function(plr)
	game:GetService("MessagingService"):PublishAsync("LiveModcall", "ModcallTicket")
end)

game:GetService("MessagingService"):SubscribeAsync("LiveModcall", function(reason, sender)
    reason = reason["Data"]
	for _,v in pairs(game.Players:GetPlayers()) do
		if v.IsMod.Value == true then
			if v.PlayerGui:FindFirstChild("ModcallNotify") then
				local gui = v.PlayerGui:FindFirstChild("ModcallNotify")
				gui.Frame.Visible = true
				print(reason)
				print(sender)
				gui.Frame.Reason.Text = reason
				gui.Frame.Username.Text = sender.Name
				gui.Frame.PlayerImage.Image = image_format1..sender.UserId..image_format2
				gui.Frame.UserId.Text = sender.UserId
				gui.ModTicket.PopOut:FireClient(v)
			end
		end
	end
end)

Forgot that SubscribeAsync returns a table. Should be good to go now.

“sender” a nil value…

local plr = game:GetService("Players").LocalPlayer

event_2:FireServer(panel.InputBox.Input.Text, plr)

Is there another way to define player?

Player is automatically defined when firing a remote event.

Ohhhh, okay. Let me try running script again!


Then what to define here?

The sender, is a player who mod called.

event.OnServerEvent:Connect(function(plr)
	game:GetService("MessagingService"):PublishAsync("LiveModcall", plr.Name.." ModcallTicket")
end)

game:GetService("MessagingService"):SubscribeAsync("LiveModcall", function(reason)
    reason = reason["Data"]
    local sender = reason:sub(reason:find(" "),#reason)
	for _,v in pairs(game.Players:GetPlayers()) do
		if v.IsMod.Value == true then
			if v.PlayerGui:FindFirstChild("ModcallNotify") then
				local gui = v.PlayerGui:FindFirstChild("ModcallNotify")
				gui.Frame.Visible = true
				print(reason)
				print(sender)
				gui.Frame.Reason.Text = reason
				gui.Frame.Username.Text = sender.Name
				gui.Frame.PlayerImage.Image = image_format1..sender.UserId..image_format2
				gui.Frame.UserId.Text = sender.UserId
				gui.ModTicket.PopOut:FireClient(v)
			end
		end
	end
end)

See if this works.

What changes you did in this script?

event.OnServerEvent:Connect(function(plr)
	game:GetService("MessagingService"):PublishAsync("LiveModcall", plr.Name.." ModcallTicket")
end)

game:GetService("MessagingService"):SubscribeAsync("LiveModcall", function(reason)
    reason = reason["Data"]
    local sender = reason:sub(reason:find(" "),#reason)
	for _,v in pairs(game.Players:GetPlayers()) do
		if v.IsMod.Value == true then
			if v.PlayerGui:FindFirstChild("ModcallNotify") then
				local gui = v.PlayerGui:FindFirstChild("ModcallNotify")
				gui.Frame.Visible = true
				print(reason)
				print(sender)
				gui.Frame.Reason.Text = reason
				gui.Frame.Username.Text = sender
				gui.Frame.PlayerImage.Image = image_format1..game.Players:GetUserIdFromNameAsync(sender)..image_format2
				gui.Frame.UserId.Text = game.Players:GetUserIdFromNameAsync(sender)
				gui.ModTicket.PopOut:FireClient(v)
			end
		end
	end
end)

You can’t just get someones user id with name.UserId. Sender is also already a string.

I used this new code and, got no errors