I am trying to get this script to prompt a purchase to the gamepass if they don't own it, but if they do then it puts the tools in the locations shown below. I keep getting this error though and I don't know what to do to fix this, any help?
local GamePassService = game:GetService("MarketplaceService")
local GamepassId = 0 -- 0 for purpose of asking
script.Parent.Touched:Connect(function(hit)
if GamePassService:UserOwnsGamePassAsync(player.UserId, GamepassId) then
game.ServerStorage.FlyingCarpet:Clone().Parent = player.Backpack
game.ServerStorage.FlyingCarpet:Clone().Parent = player.StarterGear
end
end)

2 comments
I got this error: Workspace.Part.Script:7: attempt to index nil with 'UserId'
i know, but you never told the script what is "player" you cant get UserId from nothing