I created a gamepass and put it on my map. What I would like to know is if there is any function that, if the player already has this gamepass purchased, when he clicks to buy this item in a Gui shop, instead of showing up that one screen so that the item can be purchased (game: GetService ("MarketplaceService"): PromptGamePassPurchase (game.Players.LocalPlayer, Id), does not appear there. does anyone understand and have an answer? I created a script to make this appear on the screen, but the "== nil" part, on line 14 is not working

local Gamepass1 = workspace.LEVEL2_MAP.GamePasstouch
local Id1 = 9155093
local marketingservice = game:GetService("MarketplaceService")
local debounce = false

Gamepass1.Touched:Connect(function(t)
	if t.Parent:FindFirstChild('Humanoid') then
	if debounce == false then
		debounce = true		 
 
 if marketingservice:UserOwnsGamePassAsync(game.Players[char.Name].UserId, Id1) then
print("you already have this gamepass, you can continue.")

elseif  marketingservice:UserOwnsGamePassAsync(game.Players[char.Name].UserId, Id1)  == nil then
	game:GetService("MarketplaceService"):PromptGamePassPurchase(game.Players.LocalPlayer, Id1)
end
wait(0.5)
	debounce = false
	end
	end
end)

1 comment

0

The method returns a Boolean. This is why it’s commonly used in conjunction with a conditional; it won’t ever be nil, so simply just add a false clause or use a not operand.