It works if you don't own gamepass but if you own gamepass and join you don't have it in backpack I was doing this in studio
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MPS = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local MagicCarpet = ReplicatedStorage:WaitForChild("GamePassItems"):WaitForChild("RainbowMagicCarpet")
local gamepass_id = 10008706
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function()
MPS:UserOwnsGamePassAsync(player.UserId, gamepass_id)
end)
end)
MPS.PromptGamePassPurchaseFinished:Connect(function(Player, gamepass_id, isPurchased)
if isPurchased == true then
MagicCarpet:Clone().Parent = Player.Backpack
elseif isPurchased == false then
print("Player did not purchase game pass!")
end
end)

1 comment
I have it in a server script and I did like you said and I get this error 14:03:13.164 - ServerScriptService.Script:8: attempt to index nil with 'CharacterAdded'