Greetings, I’m looking for a way on how can I make a Button, If you bought a Gamepass and clicked it a webhook will send message to discord?
Can someone help me, please?
[NOTE]: I’m not so good at scripting.
Greetings, I’m looking for a way on how can I make a Button, If you bought a Gamepass and clicked it a webhook will send message to discord?
Can someone help me, please?
[NOTE]: I’m not so good at scripting.
You should get a ScreenGui and put it into StarterGui first, then in the ScreenGui add a TextButton and change its properties to whatever you like. Then add a LocalScript into the TextButton, put
LocalScript
local button = script.Parent local remote = game.ReplicatedStorage.RemoteFunction button.MouseButton1Click:Connect(function() game.ReplicatedStorage.RemoteEvent:FireServer() end)
Server Script:
function SendToDiscord(msg) local httpservice = game:GetService("HttpService") local Data = { ["content"] = msg } Data = http:JSONEncode(Data) http:PostAsync("[Discord hook here, between the double quotes please!]", Data) end RE = Instance.new("RemoteEvent") RE.Parent = game.ReplicatedStorage RE.Name = "RemoteFunction" RE.OnServerEvent:Connect(function(plr) if game:GetService("MarketplaceService"):UserOwnsGamePassASync(plr, 5694417) then SendToDiscord(game.Players.LocalPlayer.Name.." Owns this gamepass!") end end)
Not tested yet
Reference: Discord Webhook Guide
Edit: Sorry for unfinished post earlier i accidentally posted ;-;
But, How? There’s no Webhook ID…
I would recommend you start reading this article on how webhooks work.
To guide you, here are some steps I would take:
There is a good model by Tigerism which you can find here: https://www.roblox.com/library/514586321/Discord-Webhook-API
It’s pretty simple to set up.
it’s not advanced and doesn’t involve embed.
Hi, It doesn’t work.
I tried to make it says !!setrankid [NAME] 2
Can you help me?
Event’s Place: game.ReplicatedStorge.Events.Test
I mean, I changed the message content and it doesn’t work.
Sorry I didnt quite get what you meant, could you please repeat that with more precise details?
I changed the script to this but it doesn’t work:
function SendToDiscord(msg)
local httpservice = game:GetService("HttpService")
local Data = {
["content"] = msg
}
Data = http:JSONEncode(Data)
http:PostAsync("[Discord hook here, between the double quotes please!]", Data)
end
local button = script.Parent
local remote = game.ReplicatedStorage.CheckIfPlayerHasGame
button.MouseButton1Click:Connect(function()
if game:GetService("MarketplaceService"):UserOwnsGamePassASync(game.Players.LocalPlayer, 5694417) then
SendToDiscord(';promote '..game.Players.LocalPlayer.Name..' Owns this gamepass!')
end
end)
You cannot send an HTTP request from client. Use this instead:
--//Server Script in ServerScriptService:
local remote = Instance.new("RemoteEvent", game.ReplicatedStorage);
remote.Name = "PromotionChecker"
function SendToDiscord(msg)
local http = game:GetService("HttpService")
local Data = {
["content"] = msg
}
Data = http:JSONEncode(Data)
http:PostAsync("[Discord hook here, between the double quotes please!]", Data)
end
remote.OnServerEvent:connect(function(player)
if (game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, 5694417)) then
SendToDiscord(';promote '..player.Name..' Owns this gamepass!')
end
end)
Client (where your current script is):
local button = script.Parent
local pro = game.ReplicatedStorage.PromotionChecker
button.MouseButton1Click:connect(function()
pro:FireServer();
print("Successfully sent a check to the server.")
end)
Infact, if you are storing your webhook on client, it will be easily crackable by an exploit like Synapse, and you can get your group ruined.
I would also advise not to use “;promote” and add some checks, because someone can spam the button or remote with an exploit.
Thank you so much!! It works.