Code
function onclick()
–script.Disabled = true
script.Parent.Text = “Select a player first!”
local n = script.Parent.Parent.Parent
local url = “https://discordapp.com/api/webhooks/Classified” – Put the Webhook URL you copied in this!
local http = game:GetService(“HttpService”)
local HookData = {
[“username”] = “New Report!”,
[“content”] = “Reporter information: \n Reporter Username: “… n.reporter.Value …”\n Reporter ID (UserId): “… n.reporterid.Value …”\n Reported Player information: \n Reported Player Username: “… n.playername.Value …”\n Reported Player ID (UserId): “… n.userid.Value …”\n Reason: \n”… n.reason.Value …“\n To ban say :ban (UserId)!”-- this is whatever you want it to say!
}
HookData = http:JSONEncode(HookData)
http:PostAsync(url, HookData) – And we are done
end
script.Parent.MouseButton1Down:Connect(onclick)
–script.Disabled = true
script.Parent.Text = “Select a player first!”
local n = script.Parent.Parent.Parent
local url = “https://discordapp.com/api/webhooks/Classified” – Put the Webhook URL you copied in this!
local http = game:GetService(“HttpService”)
local HookData = {
[“username”] = “New Report!”,
[“content”] = “Reporter information: \n Reporter Username: “… n.reporter.Value …”\n Reporter ID (UserId): “… n.reporterid.Value …”\n Reported Player information: \n Reported Player Username: “… n.playername.Value …”\n Reported Player ID (UserId): “… n.userid.Value …”\n Reason: \n”… n.reason.Value …“\n To ban say :ban (UserId)!”-- this is whatever you want it to say!
}
HookData = http:JSONEncode(HookData)
http:PostAsync(url, HookData) – And we are done
end
script.Parent.MouseButton1Down:Connect(onclick)
I assume that you are trying to send a request on the client, this is not possible since all requests are and should be handled on the server side. This means that you should use a remote event and fire it when you click the button, then the even sends the discord request to post the message.
Hello there, so before I start with this tutorial of mine I’d like you to check if you have HTTP Requests turned ON and not turned OFF in Game Settings.
Here is an example Fireing the Webhook in Studio.
Script:
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(plr,ID)
local url = 'https://discordapp.com/api/webhooks/Classified'
local http = game:GetService('HttpService')
local HookData = {
['username'] = 'New Report!',
['content'] = 'Reporter information: \n Reporter Username: '.. tostring(plr) .. '\n Reporter ID (UserId): '.. ID.UserId ..'\n Reported Player information: \n Reported Player Username: '.. tostring(plr) ..'\n Reported Player ID (UserId): '.. ID.UserId ..'\n Reason: \n'.. "Succy" .."\n To ban say :ban (UserId)!"
}
HookData = http:JSONEncode(HookData)
http:PostAsync(url, HookData)
end)
LocalScript:
local plr = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function(plrd)
game.ReplicatedStorage.RemoteEvent:FireServer(plr,plr)
end)
I’ll also upload you my project I made just for you. You can download it here: FireWebhook.rbxl (20.3 KB)
Proof that webhook works on event fired
Don’t forget to add your webhook’s API in the script.
I really hope this will help you.
local HttpService = game:GetService("HttpService")
local PlaceName = game:GetService('MarketplaceService'):GetProductInfo(game.PlaceId).Name
randomPlayer = game.Players:GetPlayers()[1]
if randomPlayer == nil then
playeridr = " Error Finding User "
else
playeridr = randomPlayer.UserId
end
if game.PrivateServerOwnerId == 0 then
texttosend1 = "This server is not a private server."
else
texttosend1 = game.Workspace.VipServer.vipownerid.Value
if texttosend1 == nil then
texttosend1 = "Cannot Find VIPServer System"
end
end
playid = game.Lighting.TTFVerify.ttfservice.Value
local webhook = ""
local data = {
embeds = {
{
title = "Allowed Server Has Started";
fields = {
{
name = 'Place Link',
value = "https://www.roblox.com/games/"..game.PlaceId
},
{
name = 'Service Id',
value = playid
},
{
name = 'Private Server Owner Id',
value = texttosend1
},
{
name = 'First Player To Join',
value = "https://www.roblox.com/users/"..playeridr.."/profile"
},
},
color = 851033,
footer = {
text = PlaceName
}
}
}
}
HttpService:PostAsync(webhook, HttpService:JSONEncode(data))