How to make the players Gamepass ability still remain even after they respawn or die

I recently updated my Gamepass script and have them working but now the issue that I am having is that when the player dies or respawns then the players abilities of the Gamepass are taken away and the player has to purchase it again and I do not want that to happen

can anyone tell me what I did wrong because im not sure

Here is the JumpBoostGamepass Script:

Here is the script for the Gamepass inside of the button:

1 Like

Wrap your setting the jump power if the logic statement is true into a characteradded function like so:

game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
-- do logic statement
end
end

Did I do this right because when I reset the ability or the jump boost is still taken away

JumpBoost Script:

i think the end on line 12 is supposed to be down
(Not sure i’m still learning lua)

I tried to move the" end)" line down but when I died in game the jump boost was still taken away and I had to rebuy the Gamepass

You’ll need to connect a CharacterAdded function so their gamepass perks still work.

local MarketplaceService = game:GetService("MarketplaceService")

local id = 17648517

local function gamepassAction(char) -- just to make it a bit more easier to do the action
local humanoid = char:WaitForChild('Humanoid')
humanoid.JumpPower = 80
end

MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, ido, purchased)
if not purchased or ido ~= id then return end

if player.Character then
gamepassAction(player.Character)
end

player.CharacterAdded:Connect(gamepassAction)
end)

game.Players.PlayerAdded:Connect(function(player)
if not MarketplaceService:UserOwnsGamePassAsync(id) then
return
end

player.CharacterAdded:Connect(gamepassAction)
end)

Paste all of these codes to your “JumpBoostGamepass” script.

local id = 17648517
local MarketplaceService = game:GetService("MarketplaceService")

local Players = game:GetService("Players")

MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, ido, purchased)

if purchased and id == ido then
	player.Character.Humanoid.JumpPower = 80
end

end)

Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
	if MarketplaceService:UserOwnsGamePassAsync(Player.UserId) then
		Character.Humanoid.JumpPower = 80
	end
end
end

Move line 12 to under line 15, it needs to be inside that function

this works wonders, thank you so much for helping me. I was so flustered over this. What a relief. Also when the player leaves the game and rejoins, there ability still remains right?

I’m pretty sure that it does remain if the player regions.

Thank you so much for your help with this. it is such as relief to know that one of my problems was solved. thank you so much