I am trying to make it so that when a user touches a part, a global message goes into the chat that shows in every server. It works, but only in the server that the player touched the part in and not every server that is running on the game. I have tried using game.StarterGui:SetCore(“ChatMakeSystemMessage”), and it does display in the chat but again, not to every server. I have 0 idea how I would achieve this.
--Client Script
local cs = game:GetService("CollectionService")
local rs = game:GetService("ReplicatedStorage")
local delay = 1
local sendMessage = true
for _, v in cs:GetTagged("Completion") do
v.Touched:Connect(function(hit)
local hum = hit.Parent:FindFirstChild("Humanoid")
local char = hum.Parent
local message = char.Name .. " has completed the " .. v.Name
if hum then
if sendMessage == true then
local chatMessage = game.StarterGui:SetCore("ChatMakeSystemMessage",
{
Text = "[GLOBAL]: " .. message,
Color = Color3.fromRGB(95, 0, 173),
Font = Enum.Font.SourceSansBold,
TextSize = 18
}
)
rs.SendMessage:FireServer(chatMessage)
sendMessage = false
task.wait(delay)
sendMessage = true
end
end
end)
end
--Server Script
local ms = game:GetService("MessagingService")
local cs = game:GetService("CollectionService")
local rs = game:GetService("ReplicatedStorage")
rs.SendMessage.OnServerEvent:Connect(function(player, globalMessage)
ms:SubscribeAsync("Announcement", function(msg)
msg.Data = globalMessage
end)
ms:PublishAsync("Announcement", globalMessage)
end)
As you can see, I used MessagingService. The data of the message is equal to to the message that is actually sent in chat, and I passed this variable through a SendMessage remote event that I created. That’s what I’m confused on, since the data is equal to the chat message. It might be because the data is equal to the message in a server script, but the actual message is in a local script. But SetCore() can only be used in local script, since I get an error every time I try it in a server script. If you have any questions about my script I’ll answer them.