PromptPremiumPurchaseFinished not returning player

With the release of Premium Payouts, I’m trying to add some ways to give premium players some perks. So when a premium player touches an invisible part, if they have premium then the door is locally set to not collide-able and the player can walk through. But when a player without premium touches the door, it prompts them to buy premium. This all works fine but then when the player closes the purchase gui and MarketplaceService.PromptPremiumPurchaseFinished runs, the player that it should return is returning nil.

MS.PromptPremiumPurchaseFinished:Connect(function(player)
print(player)
if player.MembershipType == Enum.MembershipType.Premium then
	print("Premium purchased")
else
	print("Premium not purchased")
end
end)

For some reason, player is returning as nil and I have no idea why. Thanks for the help.

2 Likes

I suggest using Players.PlayerMembershipChanged to also catch cases where the player buys Premium outside the game. PromptPremiumPurchaseFinished always returns after the premium modal has been closed.

https://developer.roblox.com/en-us/api-reference/event/Players/PlayerMembershipChanged

-- Handle potential Premium purchase from outside the game while user is playing
Players.PlayerMembershipChanged:Connect(function(player)
	warn("Player membership changed; new membership is " .. tostring(player.MembershipType))
	if player.MembershipType == Enum.MembershipType.Premium then
		-- Teleport player to the Premium-only place
		TeleportService:Teleport(placeID_Premium, player)
	end
end)

Example is from https://developer.roblox.com/en-us/api-reference/function/MarketplaceService/PromptPremiumPurchase (bottom of the page)

4 Likes

FYI: This code you’ve provided seems to be completely fine, if you think it’s a bug then I suggest you file an Engine Bug in #platform-feedback:engine-bugs .

1 Like