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

How would I make a gamepass work as soon as you purchase in-game?

I was wondering how I would make a gamepass thats bought in-game work without having to rejoin.

Example: If you buy a +15 speed gamepass in-game how would you make it work without rejoining the game.

2 comments

0

you could have a script that checks if the player has bought the game pass every so often.

0

^

1 answer

✓ Accepted answer

Use PromptGamePassPurchaseFinished. It is an event that will let you fire something after the player has been prompted to buy the game pass.

I don’t know what you want the player to do to be prompted to buy the game pass, so let’s just pretend here that a button, the script’s parent, is clicked (that's why this is in a LocalScript).

local player = game.Players.LocalPlayer
local gamepassID = -- put your ID here
local MarketplaceService = game:GetService(“MarketplaceService”)

script.Parent.MouseButton1Click:Connect(function() -- You can edit this to suit your needs
	MarketplaceService:PromptGamePassPurchase(player, gamepassID) -- This part is probably already in your script

	MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, gamepassID, wasPurchased) -- wasPurchased is a bool value which tells you whether or not the player bought the game pass
        if wasPurchased == true then -- if player did buy game pass
           		-- your code here
        	else
            	return
        end
    end
end

(Sorry if the formatting looks weird. I’m not used to doing this on phone right now. I will edit if necessary.)

If you have any questions, I’ll try to reply as soon as I can!

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