Hello, I wish for there to be a button that ONLY appears if they do not have a certain gamepass. When they click the button, it will prompt them to buy the gamepass.
I have tried to check using the function PlayerHasPass but that doesn’t work.
local success, message = pcall(function()
haspass = MarketplaceService:UserOwnsGamepassAsync(Player.UserID, ProductID)
end)
if haspass then
print(“Player already owns pass”) — Do not prompt purchase
else
MarketplaceService:PromptGamePassPuchase(PPlayer, ProductID)
end
Sorry it looks like some of the code didn’t show as needed, it should all work. Although you would need every Variable, the code begins from the Variable “local MarketplaceService” everything below that is needed
local MarketplaceService = game:GetService("MarketplaceService")
local Player = game.Players.LocalPlayer
local ProductID = 11067763
script.Parent.MouseButton1Click:Connect(function()
local success, message = pcall(function()
haspass = MarketplaceService:UserOwnsGamepassAsync(Player.UserID, ProductID)
end)
if haspass then
script.Parent.Visible=false
else
MarketplaceService:PromptGamePassPuchase(Player, ProductID)
end
When I click the button, it doesn’t prompt me to buy the gamepass.
Players.BlockyToby.PlayerGui.UI.UI.ImageButton.LocalScript:21: Expected 'end' (to close 'function' at line 6), got <eof>; did you forget to close 'function' at line 7?
I will close the function and see if it works then.
Thats strange, can you provide an image of the script to ensure that the forum doesn’t cut any of it out? The script works fine for me so perhaps its another issue.