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)
You were missing an end)
Proper indentation matters to prevent errors.
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) end)
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.