So I have some gamepasses that are supposed to give the player an item when they have the gamepass, but it doesn't seem to work on Online mode, but it works perfectly in studio.
What I noticed is that it seems to place the items in the backpack when the player joins, but then it gets removed after he dies, so that led me to believe the code at line 10 only ran the first line after it, and not the others.
I also verified this using :GetChildren() of Startergear and the items were not there.
This is the code:
local passId = 430308264
local potato = game.Lighting:WaitForChild("Jetpack")
function isAuthenticated(player)
return game:GetService("MarketplaceService"):PlayerOwnsAsset(player, passId)
end
game.Players.PlayerAdded:connect(function(plr) -- player is already defined
if isAuthenticated(plr) then
print(plr.Name .. " HAS BOUGHT A JETPACK!")
potato:Clone().Parent = plr.Backpack
potato:Clone().Parent = plr.StarterGear
end
end)
Please help, this is urgent.

2 comments
GamepassService is outdated an unreliable, so that's why I used MarketplaceService
Yes, I can agree that it is unreliable; yet I can guarantee this script works in Online Mode; as for I tested it myself.