Declared pcall, when calling the variable it says *unknown global*

  1. What do you want to achieve? Keep it simple and clear!

Hello, so basically, what I want to achieve is to check for errors with pcall when making a purchase of the gamepass or if the player hasn’t bought the gamepass.

  1. What is the issue? Include screenshots / videos if possible!

the issue is that when I declare pcall and call the variable it says unknow global


image

local mps = game:GetService("MarketplaceService")
local passid = 21754270

game.Players.PlayerAdded:Connect(function(player)
local haspass = false
	
	local success, err = pcall(function()
		haspass = mps:UserOwnsGamePassAsync(player.UserId, passid)
	end)
end)
1 Like

Move that part outside of the pcall function.

which part do u mean, haspass ??

You should move that if haspass or success then part outside of the pcall since the success variable is the pcall. The pcall acts like task.spawn.

1 Like

Oh, I get it now… I’m so dum LOL

Thanks btw! :smiley:

I have a question tho, how do I check when a player bought a gamepass inside the game?

If they bought it inside the game I don’t think you can check that, I believe they will have to rejoin the game to update their purchases.

1 Like