If a certain word is said in chat, it would send a webhook request

I’m making an anti-admin abuse script and I would like to have it send a webhook to a channel for one of my admins to review if an admin used :ban all for instance.

You will want these.

Player | Documentation - Roblox Creator Hub – listen for messages
HttpService | Documentation - Roblox Creator Hub – for sending a POST request to your webhook

How would I get started with that?

There are code examples.

In the Chatted listener you will want to parse the message, check if it’s a valid command, then you will want to send to your webhook with HttpService:PostAsync

Here’s a script that I made:

--Replace URL with your webhook URL and BadMessage with the message that triggers the script..
local HS = game:GetService("HttpService")
local URL = "Your_Webhook_URL_Here"
local BadMessage = ":ban cowboywoahh"

game.Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(message)
		if string.sub(message, 1, #BadMessage) == BadMessage then --I can't just do message == BadMessage because Roblox inserts an invisible character at the end of messages.
			HS:PostAsync(URL, HS:JSONEncode({content = "This user was caught saying " .. BadMessage, username = "Abuser: " .. player.Name, avatar_url = game.Players:GetUserThumbnailAsync(player.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size352x352)}))
		end
	end)
end)

The Discord message will include the user’s name, profile picture, and the banned phrase. It will look like this:
image

The best way to do this would probably be to add the HTTP post request to the function inside the admin script itself instead of trying to individually detect keywords though.

1 Like