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"
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!