Game Passes Code Doesn't Work

Hi, developers
I have a problem with that code:

local marketPlaceService = game:GetService("MarketplaceService")
local player = game.Players.LocalPlayer
local functions = require(game.ReplicatedStorage.Functions)

local decOfCodesOfGamePasses = {["Self Heal"] = 10181459; ["Jump Boost"] = 10181368;}
local gearsOfGamePasses = game:GetService("ReplicatedStorage"):WaitForChild("Gears")["Gears 
Of Game Passes"]


player.CharacterAdded:Connect(function()
for gamePass, code in ipairs(decOfCodesOfGamePasses)do
	local success, message = pcall(function()
		hasPass = marketPlaceService:UserOwnsGamePassAsync(player.UserId, code)
	end)
	if hasPass then
		print("Player has the pass")
		local tableOfGears = gearsOfGamePasses:GetChildren()
		local gearOfGamepass = functions.GetObjectsValue(tableOfGears, gamePass):Clone()
		
		gearOfGamepass.Parent = player.Backpack
	else
		print("Player doesn't has the pass")
	end
end
end)

Another detail, am I putting it right?
image
EDIT: I tried a script instead local script, but that also didn’t work.

You should be handling any verification, especially game passes, on the server.
A player can easily exploit any local scripts.

1 Like

Use a script, not a local script

1 Like

I did with some changes like the way that I got the player, but that also didn’t work.

Sorry, I found the solution. The problem is that I am using ipairs instead of pairs so it worked now.

1 Like