I made a script that sends a webhook when a player buys the gamepass in-game which looks like this:
There is a module script that handels all the gamepassId’s in order for it to be detected when a player buys the gamepass.
Gampass Purchase Info [module]
local M = {}
M.gamePasses = {
{ id = 641394093, name = "King [EARLY ACCESS]", amount = 3000 }, -- This is an example
{ id = 5272577254, name = "The name of the gamepass", amount = 2350 },
-- copy and paste the above if you want to add another gamepass
}
return M
Server script
local mps = game:GetService("MarketplaceService")
local api = require(game.ReplicatedStorage:WaitForChild("PurchaseLogAPI"))
local gamePassPurchaseInfo = require(game.ReplicatedStorage:WaitForChild("GamePassPurchaseInfo"))
local gamePasses = gamePassPurchaseInfo.gamePasses
mps.PromptGamePassPurchaseFinished:Connect(function(player, purchasedPassId, purchaseSuccess)
if purchaseSuccess then
local purchasedGamePass = nil
for _, gamePass in ipairs(gamePasses) do
if gamePass.id == purchasedPassId then
purchasedGamePass = gamePass
break
end
end
if purchasedGamePass then
api:Send(player, purchasedGamePass.id, purchasedGamePass.amount, purchasedGamePass.name)
end
end
end)
Purchase log API [Module script]
local hs = game:GetService("HttpService")
local mps = game:GetService('MarketplaceService')
local baseText = "Purchased: "
local webhook = " "
function robuxAfterTax(robux)
if robux then
return robux - (0.3 * robux)
else
print("robuxAfterTax: robux is nil")
return nil
end
end
function convertToUsd(robux)
if robux then
local taxTaken = 0.3 * robux
local robuxAfterTax = robux - taxTaken
return 0.0035 * robuxAfterTax
else
print("convertToUsd: robux is nil")
return nil
end
end
local api = {}
function api:Send(fromWho, assetId, amount, Name)
local embed = {
title = "Gamepass Purchase",
description = fromWho.Name .. " has made a purchase.",
fields = {},
url = "https://www.roblox.com/users/" .. fromWho.UserId .. "/profile",
}
local assetInfo = mps:GetProductInfo(assetId)
local assetName = assetInfo.Name
local gamepassLink = "https://www.roblox.com/game-pass/" .. assetId
if amount then
table.insert(embed.fields, {name = 'Gamepass Name', value = Name, inline = true})
table.insert(embed.fields, {name = 'Gamepass Link', value = gamepassLink, inline = true})
table.insert(embed.fields, {name = 'Robux Amount', value = amount, inline = true})
table.insert(embed.fields, {name = 'Robux You Received', value = robuxAfterTax(amount), inline = true})
else
local priceInRobux = assetInfo.PriceInRobux
table.insert(embed.fields, {name = 'Gamepass Name', value = Name, inline = true})
table.insert(embed.fields, {name = 'Gamepass Link', value = gamepassLink, inline = true})
table.insert(embed.fields, {name = 'Robux Amount', value = priceInRobux, inline = true})
table.insert(embed.fields, {name = 'Robux You Received', value = robuxAfterTax(priceInRobux), inline = true})
end
local priceInUsd = convertToUsd(amount)
table.insert(embed.fields, {name = 'USD Amount', value = "$" .. priceInUsd, inline = true})
local data = {
embeds = {embed},
}
hs:PostAsync(webhook, hs:JSONEncode(data))
end
return api
for your webhook you can use This Proxy and you can paste it in "local webhook = " " .
Don’t forget to enable HTTP Service and API Services, Don’t know? Here is a youtube video on how to do it .