UserOwnsGamepassAsync not working on joining server?

Client

print(1) -- Does print
if GamepassCheck:InvokeServer('+5 Inventory Space') then
	Line2.Buy:Destroy()
end
print(2) -- Never prints

Server

local function ReturnGamepass(player, gamepass)
	local GamepassID = PurchaseData.Gamepasses[gamepass]
	if not GamepassID then return end
	print('Checking gamepass', GamepassID) -- prints Checking gamepass 123456
	if MarketplaceService:UserOwnsGamePassAsync(player.UserId, GamepassID) then
		print('Yes') -- Does not print
		return true
	else
		print('No') -- Does not print
		return false
	end
end

GamepassCheck.OnServerInvoke = ReturnGamepass

I know the gamepass id is just 123456, it’s just there as placeholder for me not owning the gamepass, and thus this should return false, however it isn’t.

The client fires the GamepassCheck:InvokeServer() when the player joins, so does a player need to load in properly or something before the server can check for them owning a gamepass?

Probably it’s because the Id you’re inputting is not a valid one for a gamepass and would cause the Function and the RemoteFunction to yield forever. I’m not too sure on this, but consider using a valid ID

2 Likes