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.
The MarketplaceService won't always work in this case. I suggest using GamePassService, but this will only work in ROBLOX servers, ie; doesn't work in online mode. I have composed a script that should work in your case.
local potato = game.Lighting:WaitForChild("Jetpack") game.Players.PlayerAdded:connect(function(plr) if game:GetService("GamePassService"):PlayerHasPass(plr,430308264) then print(plr.Name .. " HAS BOUGHT A JETPACK!") potato:Clone().Parent = plr.Backpack potato:Clone().Parent = plr.StarterGear end end)
I have tested the script for you, it will give you your "Jetpack" after you die or reset. I hope you learned from this example.
Here are some helpful links you can use to explore further:
http://wiki.roblox.com/index.php?title=API:Class/GamePassService/PlayerHasPass http://wiki.roblox.com/index.php?title=API:Class/MarketplaceService
(I have tried to edit this answer to put in link notations, but it has not work, I apologise for the inconvenience.)