Hello! I am trying to make a discord webhook that posts a message when someone touches a part. I want the message to include the username of the person at the start. But when I use the code it posts nothing and shows a error in the script. Here is my script:
local http = game:GetService('HttpService')
local part = script.Parent
if part.Touched then
game.Players.PlayerAdded:connect(function(plr)
local Data = {
["content"] = plr.Name.." has beaten "..part.Name
}
Data = http:JSONEncode(Data)
http:PostAsync("discord webhook link here (i replaced this because I don't want anyone to use the link.))", Data)
end
This script had the 'end' at the end have a red line underneath. (
) Plus when I tried to, the webhook posted this: 'Players has beaten Mystery Stage' (this was a different script) Here is the second script I had problems with:
local http = game:GetService('HttpService')
local player = game:GetService("Players")
local part = script.Parent
if part.Touched then
local Data = {
["content"] = player.Name.." has beaten "..part.Name
}
Data = http:JSONEncode(Data)
http:PostAsync("discord webhook link here (i replaced this because I don't want anyone to use the link.))", Data)
end
Thank you.

2 comments
AstrologicalVI, what do you mean by 'instance player'?
Oh sorry I’ve been inactive, for the “Instance player” you only defined the Players Service. In order to fix that all you have to do is: local player = game:GetService(“Players”).LocalPlayer