PromptPremiumPurchaseFinished does not return player

When working with the premium purchase modal in a module script, I noticed that the player variable returned by PromptPremiumPurchaseFinished() is nil. I just implemented this, so I do not know how long this issue has been present outside of my scenario. This is incredbily frustrating as I rely on it to determine if a user is immediately given an item or not in a shop dialog.

Code:

local MarketplaceService = game:GetService("MarketplaceService")
local PremiumPromptQueue = {}
local GamepassPromptQueue = {}

MarketplaceService.PromptPremiumPurchaseFinished:Connect(function(player)
	print(player) -- Prints Nil
	print(player.Name) -- Errors
	table.insert(PremiumPromptQueue, player.Name) -- Also would Error
end)

MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player)
	table.insert(GamepassPromptQueue, player.Name)
end)

local PurchaseYield = {}

	PurchaseYield.WaitForPremiumResponse = function(plr)
		if plr.MembershipType == Enum.MembershipType.Premium then return true end
		local plrname = plr.Name
		MarketplaceService:PromptPremiumPurchase(plr)
		repeat wait(1) until table.find(PremiumPromptQueue, plrname) or plr == nil
		if plr then
			table.remove(table.find(PremiumPromptQueue, plrname))
			if plr.MembershipType == Enum.MembershipType.Premium then
				return true
			end
		else
			table.remove(table.find(GamepassPromptQueue, plrname))
		end
		return false
	end
return PurchaseYield
9 Likes

Is this a server script or local script?

5 Likes

The module is required by a server script.

2 Likes

I can confirm that it prints nil whether or not a player purchases premium via PromptPremiumPurchase()

This was also done in a server script too. This is what the script above outputs as a result:
19:46:27.336 - ServerScriptService.Script:7: attempt to index nil with 'Name' 19:46:27.337 - Stack Begin 19:46:27.337 - Script 'ServerScriptService.Script', Line 7 19:46:27.337 - Stack End

3 Likes

I don’t know if bumping as against the rules? If so I apologize, I would just like to bump this topic as it seems like a smaller thing to fix whilst still being quite important.

This bug is still a problem

3 Likes

Sorry for bumping, but it’s been several months and this issue appears to still not have been fixed. The following code easily produces the issue:

local MarketplaceService = game:GetService("MarketplaceService")
MarketplaceService.PromptPremiumPurchaseFinished:Connect(function(player)
	print(player)
end)

Player is printed as nil, rather than the actual player’s name like, according to this article, it’s supposed to. I’m attempting to use this in my game to check, after prompting a Premium purchase, if they actually bought it - so I hope it can be fixed, thanks.

3 Likes

@Iron_Legion originally replied to me on this thread asking about the script environment but I wasn’t provided any further info regarding whether or not it was added to their list of fixes for the future. Perhaps they can update us regarding the issue?

Unfortunately after so long, this is still an issue. There is currently no reliable way to tell when a player closes the prompt without upgrading their membership. Are there any updates regarding this fix, because the documentation of this event has not been updated nor has the player parameter been supplied by the event. Although all other events of this nature work as intended.

1 Like

Rip, I just encountered this problem and I see it’s been around for a while now.

I pause player movement when prompting and want to allow them to move again when they close/finish the prompt, any help would be appreciated.