This script is for sending messages from players to a chat to record everything a person says, but it only works in the Roblox Studios test and when the game is published and entered on the server for testing, it doesn't work.
local HttpService = game:GetService("HttpService")
local webhookUrl = "https://discord.com/api/webhooks/..."
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(message)
local payload = {
content = "[" .. player.Name .. "] " .. message
}
local success, response = pcall(function()
local request = HttpService:RequestAsync({
Url = webhookUrl,
Method = "POST",
Headers = {
["Content-Type"] = "application/json"
},
Body = HttpService:JSONEncode(payload),
})
return request
end)
if not success then
warn("Erro ao enviar a mensagem para o Discord:", response)
elseif response and response.StatusCode == 200 then
print("Mensagem enviada com sucesso para o Discord!")
else
if response then
warn("Erro no código de status:", response.StatusCode, response.StatusMessage)
else
warn("Resposta nula ao enviar a mensagem para o Discord.")
end
end
end)
end)