Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

how do I check if a player bought a gamepass?

this is inside a touched event that is inside a for loop. v = all the tycoons buttons. after the gamepass purchase is prompt how do I check if the player bought it? if you need the full script let me know, its like 90 lines though

if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,v.Gamepass.Value) then
												print("bought")
											else
												game:GetService('MarketplaceService'):PromptGamePassPurchase()
											end

1 answer

You're doing alright, but you forgot the player variable and the game pass id.

To get the player, I'll just use a PlayerAdded event.

game.Players.PlayerAdded:Connect(
    function(player)
        if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, 1743777) then
        end
    end
)

2 comments

0

this script is in a touched event so the player variable has already been defined. Im trying to figure out how to constantly check if the gamepass has been purchased. would I do that outside the touched event? and how

This discussion is preserved as it was. New answers, comments, and votes are closed.