How can I make a Button, If you bought a Gamepass and clicked it a webhook will send message to discord?

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 ;-;

1 Like