I have a problem with my gamepass handler
For some reason it’s completely broken and I have no idea why I have done nothing wrong but I can provide yall with the code
gamepasshandler
local MarketplaceService = game:GetService("MarketplaceService")
local gamepassID = --my gamepass Id
MarketplaceService.PromptPurchaseFinished:Connect(function(player, purchaseID, purchaseSuccess)
if purchaseSuccess == true and purchaseID == gamepassID then
print("testyes")
player.leaderstats.Crystals.Value = player.leaderstats.Crystals.Value + 100
print("hmm?")
player.leaderstats.Rank.Value = "VIP"
print("mhmh")
end
end)
print("lol")
gamepass prompter
local MarketplaceService = game:GetService("MarketplaceService")
local players = game:GetService("Players")
local player = game.Players.LocalPlayer
local gamepassID = --my gamepass id
local function promptPurchase()
local hasPass = false
print("testtr5yes")
local success, errormessage = pcall(function()
hasPass = MarketplaceService:PromptGamePassPurchase(player.UserId, gamepassID)
end)
if success then
print(player.Name.." has the VIP gamepass!")
print("test111")
else
MarketplaceService:PromptGamePassPurchase(player, gamepassID)
print("test1")
end
end
wait(3)
promptPurchase()
print("test3232")
And juse incase your curious about my leaderstats code I can provide you with it too no problem.
my leaderstats
local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("DataStore")
game.Players.PlayerAdded:Connect(function(p)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = p
local Crystals = Instance.new("IntValue", leaderstats)
Crystals.Name = "Crystals"
Crystals.Value = 10
local Rank = Instance.new("StringValue", leaderstats)
Rank.Name = "Rank"
Rank.Value = "Customer"
print("hello world")
local pUserID = "P_"..p.UserId
print("lolool")
local s, em = pcall(function()
d = DataStore:GetAsync(pUserID)
end)
if s then
Crystals.Value = d
else
warn(em)
end
end)
game.Players.PlayerRemoving:Connect(function(p)
local pUserID = "P_"..p.UserId
local d = p.leaderstats.Crystals.Value
local s, em = pcall(function()
DataStore:SetAsync(pUserID, d)
end)
if s then
print("eevrything went well")
else
warn(em)
end
end)
This is weird it was working yesterday
EDIT: every single print is working except for the prints in the gamepass handler
The output doesn’t give me any errors but it prints every single print in every script that i showed except for the gamepass handler which means that the problem is in the gamepass handler.
PromptPurchaseFinished is not superseded. There are three prompt finishes: for game passes, developer products and all other assets. Read the documentation carefully.
Anything that can be sold that isn’t a game pass or developer product is an “other asset” and will, if PromptPurchase is fired with its asset id, trigger PromptPurchaseFinished upon dismissing the dialogue after selecting either buy/take or cancel.