Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why wont my gamepass item giver give an item?

Asked by 6 years ago

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!

0
Stop using the “I’m a bit of a noob, so please go easy on me!" It just asks for people to go hard, and you’ve used that for months. User#19524 175 — 6y
0
I'm just informing people no need to be rude.. :I CaptainAlien132 225 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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

Ad

Answer this question