How do I make Roblox to discord death logs? I've been working on a script that when you die it sends an output to discord that the player has died into a specific channel as a bot. and I can't seem to get it to work.
local Players = game:GetService("Players")
local HttpService = game:GetService("HttpService")
game:GetService('Players').PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
character:WaitForChild("Humanoid").Died:Connect(function()
print(player.Name .. " has died!")
local webhook = "https://discordapp.com/api/webhooks/#####Have To Tag It Out For Certain Reasons#######"
HttpService:PostAsync(webhook, HttpService:JSONEncode(data))
end)
end)

3 comments
It gives me a Error the "Data" On line 09
@Radi3al because the variable data doesn't exist. JSONEncode takes in a table and turns it into a string for the webserver to read in JSON. I'm not sure what you want to be sending over, maybe their name would suffice.
Even then it's up to you to deal with that JSON on the other end correctly.