Hi! I am creating a game wih gamepasses. I have created a shop and I have putted the gampasses I want in. The problem is when I buy a gamepass (for example a speedcoil), I have the object but when I dead, and I respawn, I dont keep the object in my inventory. Theres the script:
local MarketplaceService = game:GetService("MarketplaceService") local players = game:GetService("Players") local gravitycoilgamepassID = 100531781 local speedcoilgamepassID = 100523532 game.Players.PlayerAdded:Connect(function(player) local success, message = pcall(function() hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, speedcoilgamepassID) end) if hasPass then print("player has the game pass") local speedcoil = game.ReplicatedStorage["SpeedCoil"]:Clone() speedcoil.Parent = player.Backpack end end) local function onPromptGamePassPurchaseFinished(player, purchasedPassID, purchaseSuccess) if purchaseSuccess == true and purchasedPassID == speedcoilgamepassID then print(player.Name .. " purchased the speed coil game pass!") local speedcoil = game.ReplicatedStorage["SpeedCoil"]:Clone() speedcoil.Parent = player.Backpack end end MarketplaceService.PromptGamePassPurchaseFinished:Connect(onPromptGamePassPurchaseFinished)
Thanks in advance! Have a nice day!
Hi issue with your script is that it activates when someone buys gamepass. An easy way to fix this issue would be to make a datastore. If needed here is a video on that Tutorial Hope this helps!!