Player dies and loses gamepass tool

  1. 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.

  2. What is the issue? Player dies and loses the tool ,also i have 3 scripts so

  3. 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.

So i just tested it out and when i load in it doesn’t give it to me, and then when i die also it doesn’t give it to me.

You must’ve done something wrong then, because:

Organisation:

image

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.

2 Likes

Just clone the tool to startergear (in the player) and the backpack. And it will always come to u

Here’s an example :

--your gamepass code here blah blah
tool:Clone().Parent = plr.StarterGear
tool:Clone().Parent = plr.Backpack

–Make sure it executes only once.

What your code should look like:

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)

I’m suprized no one knew startergear existed

3 Likes

Yeah haha I just did that and it worked I really appreciate it man, sorry for the inconvenience. I didn’t even know starter gear existed.

1 Like