Gamepass not saving

I have two game passes with the same code. One saves, one does not. Everything appears to be the same, yet the POST VER returns false for x2 speed but true for 2x cash. I repurchased speed multiple times in the same game simulation, and it never seemed to save. Anyone know how I can fix this?
Thanks

Local Script

local speed = 26544839
local cash  = 34402581
script.Parent.Fr.speed.MouseButton1Click:Connect(function() -- 2x speed
	local ver = remFu:InvokeServer(speed)
	print("POST VER: ", ver)
end)

script.Parent.Fr.cash.MouseButton1Click:Connect(function() -- 2x cash
	local ver = remFu:InvokeServer(cash)
	print("POST VER: ", ver)
end)

Server Script

local function verify(player, id)
	itd = id
	local hasPass = false
	-- Check if the player already owns the game pass
	local success, message = pcall(function()
		hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, id)
	end)
	print(hasPass)
	return hasPass
end

remoteFunction.OnServerInvoke = verify 
1 Like

there might be an error pcall has silenced, because hasPass is still on its initial value (false)

1 Like

Good idea, but unfortunately it didn’t work. SUCC was printed for both the broken and working gamepass

The handler also prints that the purchase was a success, which confuses me even more

local hasPass 
	-- Check if the player already owns the game pass
	local success, message = pcall(function()
		hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, id)
	end)
	if message then
		print("THE ERROR: ", message)
	elseif success then
		print("SUCC: ", success)
	
	end

(Handler)

local function onPromptGamePassPurchaseFinished(player, purchasedPassID, purchaseSuccess)

	if purchaseSuccess == true and purchasedPassID == speed then
		print(player.Name .. " purchased the game pass with ID " .. itd)
1 Like
  1. Why would you send a request to the server for verification if it can be done on the client?
  2. Do you check if a player has a gamepass almost immediately after purchase? If so, then this is normal behavior, since UserOwnsGamePassAsync has a cache, and it lasts about 60 seconds if I’m not mistaken, that is, after about a minute it will indicate that the player has a gamepass. Instead, I recommend using a table, when a player buys a gamepass, then enter his data there (id or nickname) and what gamepass he bought and when requesting the server, check the table, if not there, then call UserOwnsGamePassAsync to be sure.
1 Like

My initial fix:

local function verify()
	local speed = 26544839
	local cash  = 34402581
	local hasPass1 = false
	local hasPass2 = false
	local Player = game:GetService("Players"):FindFirstChildOfClass("Player")
	-- Check if the player already owns the game pass
	if MarketplaceService:UserOwnsGamePassAsync(Player.UserId, speed) then
		hasPass1 = true
		print(Player.DisplayName.."(@"..Player.Name..") has the Speed game-pass")
	end

	if MarketplaceService:UserOwnsGamePassAsync(Player.UserId, cash) then
		hasPass2 = true
		print(Player.DisplayName.."(@"..Player.Name..") has the Cash game-pass")
	end
-- If it doesn't work remove entirely the function and the remoteFunction, after you've done that, remove the comment.
end

remoteFunction.OnServerInvoke = verify

Local script:

local speed = 26544839
local cash  = 34402581
local Player = game:GetService("Players").LocalPlayer
local MPS = game:GetService("MarketplaceService")

script.Parent.Fr.speed.MouseButton1Click:Connect(function() -- 2x speed
	if MPS:UserOwnsGamePassAsync(Player.UserId, speed) then
		script.Parent.Fr.speed.Text = "You already bought this pass!"
		task.wait(.497)
		print(Marketplace:UserOwnsGamePassAsync(Player.UserId, speed))
		script.Parent.Fr.speed.Text = "Buy the speed pass." --Put the original text.
	else
		MPS:PromptGamePassPurchase(Player, speed)
	end
end)

script.Parent.Fr.cash.MouseButton1Click:Connect(function() -- 2x cash
	if MPS:UserOwnsGamePassAsync(Player.UserId, cash) then
		script.Parent.Fr.cash.Text = "You already bought this pass!"
		task.wait(.497)
		print(Marketplace:UserOwnsGamePassAsync(Player.UserId, cash))
		script.Parent.Fr.cash.Text = "Buy the cash pass." --Put the original text.
	else
		MPS:PromptGamePassPurchase(Player, cash)
	end
end)

Holy shoot, typing with my hands takes so LONG.