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)
you would check with MarketPlaceService:UserOwnsGamePassAsync
the code in MarketPlaceService.PromptGamePassPurchaseFinished
seems like it could do the job for player.CharacterAdded
, just set "isPurchased" with MarketPlaceService:UserOwnsGamePassAsync
for example:
player.CharacterAdded:Connect(function() local isPurchased = MPS:UserOwnsGamePassAsync(player.UserId, gamepass_id); if isPurchased then MagicCarpet:Clone().Parent = Player.Backpack else print("Player does not own game pass!") end end)
also i would recommend this gamepass stuff be in a server script rather than a LocalScript as if it were in the latter nobody would see the carpet