Hello everyone! I was trying to make Chat Logs for my Discord server and faced such a problem that if I send a message while in Roblox Studio, everything works fine, but if I send a message in the game itself, nothing will happen. I hope someone - will help solve the problem
And here is my script :
Script
local https = game:GetService(“HttpService”)
local webhook = “webhook url”
function sendDiscordMessage(message, name, picture)
local info = {
content = message,
username = name,
avatar_url = picture
}
local encoded = https:JSONEncode(info)
https:PostAsync(webhook, encoded)
end
game.Players.PlayerAdded:Connect(function(player)
local name = player.DisplayName .. " (@" .. player.Name .. ")"
local imageUrl = "http://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&Format=Png&Type=AvatarHeadShot&userId=" .. player.UserId
player.Chatted:Connect(function(message)
sendDiscordMessage(message, name, imageUrl)
end)
end)