GamepassService help

Hello!

I have a script that sends a message to a discord webhook which currently works completely fine however it only wants to work using “ProductService” (DevProducts) and it wont work with “GamepassService”(Gamepasses).

I want to be using a gamepass instead a devproduct since gamepasses are overall easier to track through the group sales tab plus the perk I am selling is a one time purchase (gamepass) so a devproduct isn’t really a good solution.

Here is the script:


local HTTP = game:GetService("HttpService")

local webhookurl = "https://discord.com/api/webhooks/880470604720005171/jX9OttLgb-Vfr4-UKI378TEQOsoEvQ28k0pTnTlrQwesI8jd7Szp1EWlAvz6I_PG-wtP" -- This can be found by going into your discord server settings then going to integrations then going to webhooks

local marketPlaceService = game:GetService("MarketplaceService")

local id = 1199375949

local function SendReport(player, asset)
	local data = {
		["embeds"] = {{

			["author"] = {
				["name"] = player.Name,
				["icon_url"] = "https://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&username="..player.Name
			},
			["description"] = "Purchased an Enviro 300",
			["color"] = Color3.fromRGB(239, 184, 56),
			["fields"] = {
				{
					["name"] = "Account Age:",
					["value"] = player.AccountAge,
					["inline"] = true
				},
				{
					["name"] = "User ID:",
					["value"] = player.UserId,
					["inline"] = true
				}
			}
		}},

	}
	local finaldata = HTTP:JSONEncode(data)
	HTTP:PostAsync(webhookurl, finaldata)
end

game.ReplicatedStorage.TBE300.OnServerEvent:Connect(function(player)
	marketPlaceService:PromptProductPurchase(player, id)
	
	
	marketPlaceService.PromptProductPurchaseFinished:Connect(function(p, assetid, isPurchased)
		if isPurchased then
			local player = game.Players:GetPlayerByUserId(p)
			SendReport(player, assetid)
		else
			print(player .. " Did not buy " .. assetid)
		end 
	end)
end)

The script works completely fine as of now but only with DevProducts as previously said above.

Heres a download to the fully working model (instructions of where to place everything is included)
RLXDev-DevForum.rbxm (5.6 KB)

Thanks to anyone that helps out!

PromptProductPurchaseFinished is suspended, you must use ProcessReceipt.
More information:

1 Like

What you supplied is all correct, However it doesn’t help me since I want to get rid of the DevProducts all together and swap it out for Gamepasses but whenever i swap to GamepassPurchase/GamepassPurchaseFinished it doesn’t work