I’ve written a program using the MessagingService. I just recently discovered this Service so I wrote this souly on the purpose of messing around with it. The function of the program is to allow the User to write !announce within the ROBLOX chat, followed by whatever the message given. It will then use that and create a SystemMessage via ChatMakeSystemMessage. The program hasn’t given and output or shown any present syntax issues. I’m not sure what’s wrong, but I have a hunch it may be an issue with comparing the conjoined string and chat:sub() result on line 16?
--// Script under ServerScriptService
local messagingService, subscription = game:GetService("MessagingService"), "GlobalAnnounce"
local coreGui = game:GetService("StarterGui")
local playerService = game:GetService("Players")
local userList = {
[74087102] = "Feahren"
};
local prefix, call = [[!]], [[announce ]]
playerService.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(chat, recipient)
if not (userList[player.UserId]) or recipient then return end
if (chat:sub(#prefix, #call):lower() == string.lower(prefix..call)) then
local token = chat:FilterStringForBroadcast(chat:sub((#prefix+#call)), player)
messagingService:PublishAsync(subscription, token)
end
end)
end)
messagingService:SubscribeAsync(subscription, function(received)
local data, tStamp = unpack(received)
coreGui:SetCore("ChatMakeSystemMessage", {
Text = "[ANNOUNCEMENT]: "..data,
Color = Color3.fromRGB(255,255,255),
Font = Enum.Font.SourceSansBold
});
end)
