Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i make roblox to discord death logs?

Asked by 4 years ago
Edited by DanzLua 4 years ago

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)

1 answer

Log in to vote
0
Answered by
DanzLua 2879 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

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.

0
It gives me a Error the "Data" On line 09 SillyMeTimbers -5 — 4y
0
@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. DanzLua 2879 — 4y
0
Even then it's up to you to deal with that JSON on the other end correctly. DanzLua 2879 — 4y
Ad

Answer this question