This event fires when the game server recognizes that a player’s membership has changed. Note, however, that the server will only attempt to check and update the membership after the Premium modal has been closed. Thus, to account for cases where the user purchases Premium outside of the game while playing, you must still prompt them to purchase Premium; this will then show a message telling them they’re already upgraded and, once they close the modal, the game server will update their membership and trigger this event.
To learn more about and incorporating Premium into your game, and monetizing your game with the Premium Payouts system, take a look at this article.
MarketplaceService/PromptPremiumPurchase, used to prompt a user to purchase Premium
MarketplaceService/PromptPremiumPurchaseFinished, fires when the Premium purchase UI closes
Handling Premium Membership Changes
The function in the code sample runs after the game server confirms a player’s membership has changed. It demonstrates how you can grant players access to Premium benefits (or revoke them) when their membership status changes.
local Players = game:GetService("Players") local function grantPremiumBenefits(player) -- Grant the player access to Premium-only areas, items, or anything you can imagine! end local function playerAdded(player) if player.MembershipType == Enum.MembershipType.Premium then grantPremiumBenefits(player) end end local function playerMembershipChanged(player) print("Received event PlayerMembershipChanged. New membership = " .. tostring(player.MembershipType)) if player.MembershipType == Enum.MembershipType.Premium then grantPremiumBenefits(player) end end Players.PlayerAdded:Connect(playerAdded) Players.PlayerMembershipChanged:Connect(playerMembershipChanged)