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
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
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?