MarketplaceServer:PromptGamePassPurchasedFinished is an event which fires whenever a gamepass prompt has been closed. An event is not what you put into a condition of an if statement.
Don't know what an event is? You've probably seen this before:
local part = script.Parent
local function onTouched(hit)
print("sOmeBody ToucHa mAh SpAGHeT!!")
end
part.Touched:Connect(onTouched)
You even used the MouseButton1Down event of GuiButtons. Basically events allow functions to "fire" or "happen" when something takes place, such as when a part has been Touched. What you need now isn't an event.
What you are probably looking for is MarketplaceService:UserOwnsGamePassAsync which is a function that returns a boolean (true/false, yes/no). Now you can put this in the condition of an if statement. It's usage would be:
local mps = game:GetService("MarketplaceService")
local playerId = 1234567890
local gamePassId = 0987654321
if mps:UserOwnsGamePassAsync(playerId, gamePassId) then
else
end
If I got what you wanted, your entire script would look like this:
local player = game:GetService("Players").LocalPlayer
local mps = game:GetService("MarketplaceService")
local gamePassId = 12345
script.Parent.MouseButton1Down:Connect(function()
if mps:UserOwnsGamePassAsync(player.UserId, gamePassId) then
else
mps:PromptGamePassPurchase(player, gamePassId)
end
end)
2 comments
You're better off checking on player connect if they own it, and awarding it then.
well one thing I immediately notice is that on line 4 you misspelled ".PromptGamePassPurchaseFinished"