I have this code to check for a gamepass to give a gear:
local bubblegum = game.ServerStorage.Bubblegum
local gamePassID = 7750280
game.Players.PlayerAdded:Connect(function(player)
local hasPass = false
local success, message = pcall(function()
hasPass = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, gamePassID)
end)
if not success then
warn("Error while checking if player has pass: " .. tostring(message))
return
end
if hasPass == true or player.UserId == 84182809 or player.UserId == 77108475 then
print(player.Name .. " owns the game pass with ID " .. gamePassID)
bubblegum:Clone().Parent = player.Backpack
bubblegum:Clone().Parent = player.StarterGear
local hatsFolder = Instance.new("Folder", game.ReplicatedStorage)
hatsFolder.Name = "Hats" .. player.UserId
end
end)
Most of the time, however, the output is:
GamePassId ‘7750280’ is not of type Game Pass. Please use MarketplaceService:PlayerOwnsAsset instead.
I’ve looked for how to use PlayerOwnsAsset for a while, yet still do not understand how it works so I am unable to implement it into my code.
I’d love for someone to explain how it works
Here’s the gamepass: Kidanger Bubbblegum - Roblox