I wanted to make a message broadcast in chat when you type a command, for example, the /me command. I know how to make a system message but no clue how to make this code. For example, I would type /announce hi in chat and "hi" would pop up in the chat as a system message.
well you need to keep track of who is allowed to do commands, and then when they chat you process the command..
like this:
local admins = {"void_node", "builderman", "badcc", etc} local Players = game:GetService("Players") local commands = { announce = function(msg) print(msg) end, --add more command processors } Players.PlayerAdded:Connect(function(player) for _, admin in pairs(admins) do if(admin.Name:lower() == player.Name:lower()) then player.Chatted:Connect(onChatted) end end end) function onChatted(msg) local command = msg:match("^%\(%w+)"); local processor = commands [command] if processor then processor(msg:sub(#command + 1)) end end
now if you chat something like this:
"/announce Server is shutting down"
it will print in the output Server is shutting down