Attempt to index number with 'VIP_ID'?

I have this function here where it awards the player after the round ends. This error that it’s throwing me is making me confused as I think it’s occurring when I’m trying to find if the player owns the gamepass but personally I don’t see any problems with this code

function RoundClass:AwardPlayer(player) -- award the player points and wins after the round ends
	local VIP_ID = 41982359 -- id for vip gamepass
	
	local profile = StatsManager:GetData(player)
	
	-- check if the player has the gamepass and wrap it around a pcall to catch errors and what not
	local success, result = pcall(function()
		return MarketPlaceService:UserOwnsGamePassAsync(player.UserId, VIP_ID)
	end)
	
	-- if the player has the gamepass, reward them with the vip award, if not reward them with the default award
	if success then
		if result then
			profile.Points += self.VIPAward
			profile.Wins += 1
		else
			profile.Points += self.RoundAward
			profile.Wins += 1
		end
	else
		error("There's an error trying to figure out if the player owns the gamepass: " .. result)
	end
end

This is the error that it’s giving me:

I don’t understand about the pcall I rarely use that and I use that as ignoring errors, checking if it has error or whatever, I’ll just use function and return the boolean if the user owns the gamepass.

I recommend use function to check, but Idk if you use that correctly.
Idk I’m just thinking. I didn’t learn pcall much.

Yes! I hate my english, now I hope you understand it

1 Like

Try printing the id inside of the pcall

I’m uncertain on what I’ve done but miraculously it started to work again though I don’t recall on editing the code. (!?!??!)

Thanks to everyone who tried and help.

2 Likes

Also Pcall can throw errors falsely, I experienced this so I have to use function instead.

1 Like