I'm trying to make a script that gives a player an item if they have purchased the gamepass. The game is in Filtering Enabled by the way.
gpid = (4676621) tools = {"Flashlight"} GPS = game:GetService("GamePassService") function respawned(char) player = game.Players:FindFirstChild(char.Name) print("Respawned") if char:FindFirstChild("Head") ~= nil then print("It's a Player!") if GPS:PlayerHasPass(player, gpid) then print("Has GPID") for i = 1,#tools do game.Lighting:FindFirstChild(tools[i]):Clone().Parent = player.Backpack end end end end game.Workspace.ChildAdded:connect(respawned)
I'm a bit of a noob, so please go easy on me!
Don't use GamePassService, instead use MarketplaceService
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.userId,gpid) then
The first argument is the player's user ID, and the second is the gamepass ID