What do you want to achieve? I want to make it so that when the player dies they keep the tool from the game pass.
What is the issue? Player dies and loses the tool ,also i have 3 scripts so
What solutions have you tried so far? I have not looked anywhere but the recommended doesn’t show.
this is the serverGamepassManager
local gc = game.ReplicatedStorage.GamepassTools:WaitForChild("GravityCoil"):Clone()
local id = 24758824
ms.PromptGamePassPurchaseFinished:Connect(function(player, purchasePassId, purchasesuccess)
if purchasesuccess == true and purchasePassId == id then
print(player.Name.. " Purchased the get gravity coil gamepass")
gc.Parent = player.Backpack
end
end)
You need to wrap the tool giving inside a “CharacterAdded” event that way each time a new character is added a check is performed to determine if the player (of which the character model belongs to) owns the gamepass and then decides whether or not to award the tool accordingly. Also originally you were only making a single clone of the tool and then parenting it to the player’s backpack (which means that future players who bought the gamepass wouldn’t receive the tool) in this new version a clone is made every time the gamepass check comes back as true so that a new cloned tool can be placed in the player’s backpack.
local players = game:GetService("Players")
local ms = game:GetService("MarketplaceService")
local rs = game:GetService("ReplicatedStorage")
local gt = rs:WaitForChild("GamepassTools")
local gc = gt:WaitForChild("GravityCoil")
local id = 24758824
players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
if ms:UserOwnsGamePassAsync(player.UserId, id) then
print(player.Name.." owns the gravity coil gamepass!")
local clone = gc:Clone()
clone.Parent = player:WaitForChild("Backpack")
end
end)
end)
ms.PromptGamePassPurchaseFinished:Connect(function(player, productId, isPurchased)
if isPurchased then
print(player.Name.." purchased the gravity coil gamepass!")
local clone = gc:Clone()
clone.Parent = player:WaitForChild("Backpack")
end
end)
Copy & paste this exactly as it is into a server script.
local gc = game.ReplicatedStorage.GamepassTools:WaitForChild("GravityCoil"):Clone()
local gca = game.ReplicatedStorage.GamepassTools:WaitForChild("GravityCoil"):Clone()
local id = 24758824
ms.PromptGamePassPurchaseFinished:Connect(function(player, purchasePassId, purchasesuccess)
if purchasesuccess == true and purchasePassId == id then
print(player.Name.. " Purchased the get gravity coil gamepass")
gc.Parent = player.Backpack
gca.Parent = player.StarterGear
end
end)