I was trying to make a sword gamepass based off of TheDevKing’s tutorial. I followed steps exactly and even looked at the DevHub article about it, but I am still receiving an error that I am confused about. This was the error message that appeared:
https://developer.roblox.com/en-us/api-reference/event/MarketplaceService/PromptGamePassPurchaseFinished
Also, PromptGamePassPurchaseFinished did not autofill when I was writing it.
My script from a serverscript is below:
Script:
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local GamepassId = 12493769
game.Players.PlayerAdded:Connect(function(player)
local success, message = pcall(function()
haspass = MarketplaceService:UserOwnsGamePassAsync(player.UserId,GamepassId)
end)
if haspass then
print("Player has the gamepass")
local Sword = game.ReplicatedStorage.ClassicSword:Clone()
Sword.Parent=player.Backpack
end
end)
local function onPromptGamepassPurchaseFinished (player,purchasedPassId,purchaseSuccess)
if purchaseSuccess and purchasedPassId == GamepassId then
print(player.Name .. " purchased the gamepass!")
local Sword = game.ReplicatedStorage.ClassicSword:Clone()
Sword.Parent = player.Backpack
end
end
MarketplaceService:PromptGamePassPurchaseFinished:Connect(onPromptGamepassPurchaseFinished)