I'm awarding items from gamepasses and everything works except i can't seem to save them after death and rejoining the game.I've tried many different alternatives but to no avial.This script here is my latest attempt to make it work.
Thanks for your time.
local GC = player.Backpack:WaitForChild("GravityCoil",2) game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(character) if marketplaceService:PlayerOwnsAsset(player, gamePassId) then if GC == nil then GravityCoil:Clone().Parent = player.Backpack end end end) end)
Well if the players had to buy a gamepass, you don't need to save them or anything, just check if they own the gamepass. We're going to use the PlayerAdded event for this one.
local GAMEPASS_ID = 123 local marketplaceService = game:GetService("MarketplaceService") local gravityCoil = game.ServerStorage.Tools.GravityCoil game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(character) if marketplaceService:PlayerOwnsAsset(player, GAMEPASS_ID) then gravityCoil:Clone().Parent = player.Backpack end end) end)
We don't need to save the GravityCoil inside the player, we can just put it inside of ServerStorage. You can also clone to StarterGear if you'd like. I just chose this way as an easy method of allowing the player to buy the gamepass when they're in-game and still get the coil when they respawn, but there are other ways to do that.