Hello, Everybody
I have a store in my game where the player can buy gamepasses. Lets the player purchases a gamepass, but if he clicks again on the button he can purchase it again. That is the problem i am facing right now. A player can purchase 1 gamepass multiple times
local Script
local Players = game:GetService("Players")
local gamePassID = 63974938
local purchase = script.Parent
local MarketplaceService = game:GetService("MarketplaceService")
local function promptPurchase()
local player = Players.LocalPlayer
local hasPass = false
local success, message = pcall(function()
hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamePassID)
end)
if not success then
warn("Error while checking if player has pass: " .. tostring(message))
return
end
if hasPass then
print("Gamepass is owned")
-- Player already owns the game pass; tell them somehow
else
print("Gamepass not owned")
-- Player does NOT own the game pass; prompt them to purchase
MarketplaceService:PromptGamePassPurchase(player, gamePassID)
end
end
purchase.Activated:Connect(promptPurchase)
The gamepass-owned print statement never runs even if the game pass actually is. I think the UserOwnsGamePassAsync built-in function might not work.