How do I script a gear to be given when someone owns a certain gamepass?

I’m making a gear within my game that will need a gamepass to be used and given in-game, how do I actually do this?

I’ve got the gear ready, it’s giving the item when they’ve bought the gamepass that I need help with.

Use the following services below:

local gear = path.to.gear
local gamepassId = 00000
local marketPlace = game:GetService("MarketplaceService")

game.Players.PlayerAdded:Connect(function(player)
    if marketPlace:UserOwnsGamePassAsync(player.UserId,gamepassId) then
       gear = gear:Clone()
       gear.Parent = player.Backpack
    end
end)
3 Likes