Problem with gamepass handler

Hello scripters once again!!!

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

1 Like

It should be

MarketplaceService.PromptGamePassPurchaseFinished:Connect(function
2 Likes

That doesn’t work too, I don’t know what’s wrong.

Could you show us the output? Doing so makes it 1000x times easier to spot the issue.

1 Like

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.

I the future, you need to read Roblox Devloper Hub before coming to the forum.

I found this:


https://developer.roblox.com/en-us/api-reference/event/MarketplaceService/PromptPurchaseFinished

PromptPurchaseFinish is superseded by the other two functions.

1 Like

That’s what that other guy recommended me to use earlier in the conversation but that still doesn’t work.

Which means that the problem isn’t from the:

MarketplaceService.PromptGamePassPurchaseFinished:Connect(function()

I don’t know what the problem is.

Use all lower case for function.

You have no numbers there.

1 Like

I know both are just examples that I have sent but I have made sure to put my gamepassID.

This may be your issue. Check up on that, try a few different ID variant of the gamepass.

1 Like

Okay thanks for trying to help I will try and fix this.

1 Like

PromptPurchaseFinished is not superseded. There are three prompt finishes: for game passes, developer products and all other assets. Read the documentation carefully.

2 Likes

All other assets? what is the other assets that is there that you can use PromptPurchaseFinished to see if the player finished the prompt with it?

I don’t see anything other than gamepasses and developer products, am I missing something? what’s those “other assets”?

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.

1 Like