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!

4 comments
Its work but now I have the objects although I did not buy them.
Ok your going to want to make sure the player doesn't start with them
And make sure the part where it gives u the tool for free to remove
Also u may want to test it on a different account and see how it works, because it got datastore