How do you test if game passes work?

How do you test if game passes work?

2 Likes

you can press f5 in studio or click on Play in studio to test the game, you will not be charged any robux if you buy any gamepass in studio wile testing.

Itā€™s a game pass though, like I have to buy it on the website. Not a dev product/micro transaction.

you can refer this video.

If you need to test how a gamepass works, you can buy a gamepass through studio without any charge. If you do not have any prompts that allow the user to buy said gamepass in your game, you can use a simple script like this, and enable it when testing, when you want to test a certain gamepass:

local marketplace = game:GetService("MarketplaceService")
local GamepassID = 0 --Replace it with the gamepass ID
game.Players.PlayerAdded:Connect(function(player)
	repeat task.wait() until player.Character ~= nil
	marketplace:PromptGamePassPurchase(GamepassID)
end)

Unlike developer products though, it is not a one time purchase, but when you test it in studio, it acts like one. So if you are testing this, you must check if :UserOwnsGamePassAsync() many times in your scripts, and not just on join. Usually however, this can be done with a loop, or other methods depending on the gamepass you are making.

3 Likes

For me, I need third party purchases on to test gamepasses in Studio, and then they still donā€™t detect purchase anyway. I had to waste 1 robux over and over just to test. I kept deleting and rebuying a 1 robux test gamepass, lol.

Do you need to enable 3rd party sales to allow gamepasses? Or just to be able to promt them?

just set gamepass price to 0 and in alt account or on your account use it.

I donā€™t believe you can set to 0. But I didnā€™t realize you could promt a gamepass in script. That works.

To prompt them yes. That is the only reason and I donā€™t know why they count as a third party sale when the gamepass is for your gameā€¦(I did test all of these in a group, groups might work differently idk) However these donā€™t require 3rd party sale permission:

Developer Products prompts and purchase , and :UserOwnsGamePassAsync

1 Like

Gotcha, thanks. I guess the risk with leaving third party on is a free model in the game that promts some other games game passes.

So Iā€™m having issues. I do this:
ā€“ this will open a prompt to purchase game pass, I purchase it. And yet the game thinks I donā€™t have it when I leave and rejoin.

local marketplace = game:GetService("MarketplaceService")
local GamepassID = 175346023 --Replace it with the gamepass ID
game.Players.PlayerAdded:Connect(function(player)
	repeat task.wait() until player.Character ~= nil
	game:GetService("MarketplaceService"):PromptGamePassPurchase(player, GamepassID)
end)
local gamepassId = 175346023 -- Gamepass ID
local service = game:GetService("MarketplaceService")
game.Players.PlayerAdded:Connect(function(player)
	print("new player")
	if (service:UserOwnsGamePassAsync(player.UserId, gamepassId)) then
	end
end)

It doesnā€™t recognize that I own the pass?

you donā€™t own the gamepass when you ā€œleaveā€

Think of the Gamepass test, as a developer product. They act very similar in tests.

After you buy the gamepass, any use of :UserOwnsGamePassAsync will return true, if you are in the same test session as when ā€˜test buying itā€™.

A way to fix this:

  • Add a task.wait() after print("new player") to an amount of time that you need, in order to finish the prompt. This is the most simplest, or you probably could wait until the proccess is done using the marketplace service if needed,

Whenever you leave a test session, you will always lose the data in the last session, other then data stores.

This is also why some developers just make it one robux and buy it, although sometimes this isnā€™t always a option

Yea I just ended up doing the 1 robux, have to make sure you know? lol

But I see what you mean, itā€™s tough to trust that though. Since I want to test with a player added event.

I mean yes, It is hard. If you needed to test the player added, I use just a task.wait(). For me it gives a similar output result to a person joining after buying it from the website. I also know some games do save gamepasses, with data stores, for example like bedwars, which allows the developers to add a ā€œgiftingā€ system, by using this datastore. But yes, you canā€™t quite get the same result, unless you own it yourself.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.