A possible issue with my gamepass system

Hello,

Recently, I’ve been working on a gamepass system that uses a dictionary to see if user owns a specific gamepass or not, and I received complaints about testers not receiving the gamepasses that they bought. I don’t know if my system has an issue or not.

Code:

local Gamepasses = {
{
Name = “AKM”,
ID = 14388127,
Directory = game.ServerStorage.PassStorage.AKM,
Cost = 450,
},
{
Name = “Access Pass”,
ID = 14404925,
Directory = game.ServerStorage.PassStorage.AccessPass,
Cost = 50,
},
{
Name = “RPG-7”,
ID = 14448110,
Directory = game.ServerStorage.PassStorage[“RPG-7”],
Cost = 1500,
},

local PassStorage = game.ServerStorage
local Marketplace = game:GetService(“MarketplaceService”)

game.Players.PlayerAdded:Connect(function(player)
for key, value in pairs(Gamepasses) do
if Marketplace:UserOwnsGamePassAsync(player.UserId, value.ID) then
PassStorage:FindFirstChild(value.Name):Clone().Parent = player.Backpack
PassStorage:FindFirstChild(value.Name):Clone().Parent = player.StarterGear
end
end
end)

Any feedback would be much appreciated!

i think i found the mistake in your i,v loops here take this table as an example.

local table = {
  name = AKM
  Value = 123 
}

so when doing i, v in pairs with table, the i is actualy name and the v is AKM
so u are making mistake when doing value.ID etc… so if you try printing the value.name it will print nil

I think I see one problem:

Name = “Access Pass”,
ID = 14404925,
Directory = game.ServerStorage.PassStorage.AccessPass,
Cost = 50,
}

PassStorage:FindFirstChild(value.Name):Clone().Parent = player.Backpack

the Name doesn’t match the FolderName for this item so it won’t find the folder:
your asking to FindFirstChild with the name “Access Pass” but the folder name doesn’t have any spaces