Test Gamepass Purchase Not Working

so i have a slap battles-like game where i have an ability that needs robux to purchase the problem is that i cant test buy the gamepass to make sure it works correctly


heres my code:

script.Parent.MouseClick:Connect(function(player)
local smacks = player.leaderstats.Smack
local equipped = player.Equipped
local mpc = game:GetService(‘MarketplaceService’)
local ds4 = game:GetService(“DataStoreService”):GetDataStore(“–GamePass”)
local key4 = “GamePass-”…player.userId
local currency4 = {}

local GamePassID = 1143117061
local GamepassPurchased = false

local pan = player.leaderstats.Cola
local panvalue = "POWER"
local sfxpart = script.Parent.Parent.Parent.SFXpart
local yes = sfxpart.Yes
local yesS = sfxpart.YesSound
local no = sfxpart.Rejected
local noS = sfxpart.NoSound

if mpc:UserOwnsGamePassAsync(player.UserId, GamePassID) or table.find(currency4, GamePassID) then-- 0 is how much you need for it
	equipped.Value = 5-- your value in the glove DUH
	pan.Value = panvalue
	yes.Enabled = true
	yesS:Play()
	wait(0.5)
	yes.Enabled = false
else
	no.Enabled = true
	noS:Play()
	mpc:PromptGamePassPurchase(player, GamePassID)
	wait(0.5)
	no.Enabled = false
end

end)

Player.userId is deprecated, use Player.UserId instead. Maybe that’s why?

what do you mean by that could u show it in the code?

In this part

30char

ah but i dont even use that part since i tried making a data store system to save player receipts but it ended up not working

1 Like

Is your problem you being able to purchase the gamepass again or nothing happening when you purchase it?

i think this previous topic might help you!

Your code is correct. Gamepass cannot be purchased in the studio, a test purchase of the gamepass is needed to activate the PromptGamePassPurchaseFinished event, if you do not have this gamepass, then UserOwnsGamePassAsync will return false and this is normal.
You can create a new gamepass, it will automatically be in your inventory, thereby checking the functionality of the code.