Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do i make roblox to discord death logs?

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

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.

3 comments

0

It gives me a Error the "Data" On line 09

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.

0

Even then it's up to you to deal with that JSON on the other end correctly.

This discussion is preserved as it was. New answers, comments, and votes are closed.