Hello guys, So i made a gamepass script in the serverscriptservice and decided not to do in starterscript(Because i already made the rest of the dev products in that script) so i tried to do it and this thing is not working!
local function promptpurchase(receiptInfo)
local userId = receiptInfo.PlayerId
local productId = receiptInfo.ProductId
local haspurch = false
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 = productFunctionsgamepass[productId]
local success, result = pcall(handler, receiptInfo, player)
if success then
-- The user has received their benefits!
-- return PurchaseGranted to confirm the transaction.
haspurch = Marketplaceservice:UserOwnsGamePassAsync(player.UserId, handler)
player.PlayerGui.ScreenGui.Purchasesucessfull.Visible = true
return Enum.ProductPurchaseDecision.PurchaseGranted
else
warn("Failed to process receipt:", receiptInfo, result)
end
end
end
Marketplaceservice.PromptGamePassPurchaseFinished:Connect(promptpurchase)
this is the product function
productFunctionsgamepass[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