Gamepass is not working!

Hello guys, I have a issue with the gamepass that i want to create well it is not working out!

the rest of them is dev products while the last is the gamepass!

local devproIDGod = 1650733652
local devproIDsuper = 1650731748
local devproIDultra = 1650730956
local devproIDpro = 1650730083
local devproIDnoob = 1650729210
local VIP = 259204857
local Marketplaceservice = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local productFunctions = {}

-- Gives the user 100,000 cash
productFunctions[1650729210] = function(receipt, player)
	local leaderstats = player:WaitForChild("leaderstats")
	local cash = leaderstats:WaitForChild("Cash")
	if cash then
		cash.Value += 100000
		player.PlayerGui.ScreenGui.Purchasesucessfull.Visible = true
	end
end

-- Gives the user 100,000,000
productFunctions[1650730083] = function(receipt, player)
	-- make it that when it is run it would give player 100000000
	local leaderstats = player:WaitForChild("leaderstats")
	local cash = leaderstats:WaitForChild("Cash")
	if cash then
		cash.Value += 100000000
		player.PlayerGui.ScreenGui.Purchasesucessfull.Visible = true
	end
end

-- Gives the user 1b
productFunctions[1650730956] = function(receipt, player)
	-- make it that when it is run it would give player 100000000
	local leaderstats = player:WaitForChild("leaderstats")
	local cash = leaderstats:WaitForChild("Cash")
	if cash then
		cash.Value += 1000000000
		player.PlayerGui.ScreenGui.Purchasesucessfull.Visible = true
	end
end

-- Gives the user 100b
productFunctions[1650731748] = function(receipt, player)
	-- make it that when it is run it would give player 100000000
	local leaderstats = player:WaitForChild("leaderstats")
	local cash = leaderstats:WaitForChild("Cash")
	if cash then
		cash.Value += 100000000000
		player.PlayerGui.ScreenGui.Purchasesucessfull.Visible = true
	end
end

-- Gives the user 1T
productFunctions[1650733652] = function(receipt, player)
	-- make it that when it is run it would give player 100000000
	local leaderstats = player:WaitForChild("leaderstats")
	local cash = leaderstats:WaitForChild("Cash")
	if cash then
		player.PlayerGui.ScreenGui.Purchasesucessfull.Visible = true
		cash.Value += 1000000000000
	end
end
-- Gives the player vip
productFunctions[259204857] = function(receipt, player)
	local vip = player:WaitForChild("VIP")
	local gamepassvip = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId , VIP)
	if gamepassvip then
		if vip then
			player.VIP.Value = true
			player.PlayerGui.ScreenGui.Purchasesucessfull.Visible = true
		end
	end
	
end

local function processReceipt(receiptInfo)
	local userId = receiptInfo.PlayerId
	local productId = receiptInfo.ProductId

	local player = Players:GetPlayerByUserId(userId)
	if player then
		-- Get the handler function associated with the developer product ID and attempt to run it
		local handler = productFunctions[productId]
		local success, result = pcall(handler, receiptInfo, player)
		if success then
			-- The user has received their benefits!
			-- return PurchaseGranted to confirm the transaction.
			player.PlayerGui.ScreenGui.Purchasesucessfull.Visible = true
			return Enum.ProductPurchaseDecision.PurchaseGranted
			
		else
			warn("Failed to process receipt:", receiptInfo, result)
		end
	end
end

Marketplaceservice.ProcessReceipt = processReceipt
1 Like

This will only hook Dev product purchases to the function and not gamepasses purchases.

MarketplaceService.PromptGamePassPurchaseFinished:Connect(...)

Will fire once a player has completed a game pass purchase prompt.

would it still work with dev products?

You would need to use them both on their own.