Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Log only certain messages through webhooks?

Hi! So I have this script:

` local url = "MyDiscordWebhook"

local http = game:GetService("HttpService")

game.Players.PlayerAdded:Connect(function(player) player.Chatted:connect(function(msg)

	local data = {
		['embeds'] = {{
			color = 00000,
			title = "**Code logger**",
			fields = {
				{
					name = player.Name,
					value = msg,
				}
			}
		}}
	}
	local newdata = http:JSONEncode(data)
	http:PostAsync(url,newdata)
end)

end) `

I'm quite new with scripting, this logs every single message sent, however, is it possible to make it so it only logs when a certain message is said? For example, it'll only log when someone says "ABCD"

1 answer

✓ Accepted answer

Use if statements, if you want to log if it finds the word use :find, but if you want it only to log if its a certain word check if the message is equal to your word To check is the message is equal to the word

local url = "MyDiscordWebhook" 
local http = game:GetService("HttpService")
local wordtocheck = "" -- put your word here
game.Players.PlayerAdded:Connect(function(player) 
player.Chatted:connect(function(msg)
if msg:lower() == wordtocheck:lower() then
    local data = {
        ['embeds'] = {{
            color = 00000,
            title = "**Code logger**",
            fields = {
                {
                    name = player.Name,
                    value = msg,
                }
            }
        }}
    }
    local newdata = http:JSONEncode(data)
    http:PostAsync(url,newdata)
end
end)
end)

To check if a word you given is there

local url = "MyDiscordWebhook" 
local http = game:GetService("HttpService")
local wordtocheck = "" -- put your word here
game.Players.PlayerAdded:Connect(function(player) 
player.Chatted:connect(function(msg)
if msg:lower():find(wordtocheck:lower()) then
    local data = {
        ['embeds'] = {{
            color = 00000,
            title = "**Code logger**",
            fields = {
                {
                    name = player.Name,
                    value = msg,
                }
            }
        }}
    }
    local newdata = http:JSONEncode(data)
    http:PostAsync(url,newdata)
end
end)
end)

If this helped mark this as your answer!

This discussion is preserved as it was. New answers, comments, and votes are closed.