Gamepass Giver wont work

local Lighting = game.Workspace.GamepassTools
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local gamepassId = 94574569 --Put the ID of the asset here
local toolNames = {"GamepassBike"} -- No comma at end
local toolsParent = Lighting

local function onPlayerAdded(player)
    local function onCharacterAdded(character)
        if MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamepassId) then
            for i = 1, #toolNames do
                local tool = toolsParent:FindFirstChild(toolNames[i])
                if tool then
                    local clone = tool:Clone()
                    clone.Parent = player.Backpack
                end
            end
        end
    end

    if player.Character then
		onCharacterAdded(player.Character)
    end
    player.CharacterAdded:Connect(onCharacterAdded)
end

Players.PlayerAdded:Connect(onPlayerAdded)

This won’t work but for some reason this works:


local Lighting = game.Workspace.GamepassTools
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local gamepassId = 95494845 --Put the ID of the asset here
local toolNames = {"GoldenGlock"} -- No comma at end
local toolsParent = Lighting

local function onPlayerAdded(player)
    local function onCharacterAdded(character)
        if MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamepassId) then
            for i = 1, #toolNames do
                local tool = toolsParent:FindFirstChild(toolNames[i])
                if tool then
                    local clone = tool:Clone()
                    clone.Parent = player.Backpack
                end
            end
        end
    end

    if player.Character then
		onCharacterAdded(player.Character)
    end
    player.CharacterAdded:Connect(onCharacterAdded)
end

Players.PlayerAdded:Connect(onPlayerAdded)

Please help with the first one, I need to get this fixed.

Is a tool named “GamepassBike” have a parent of game.Workspace.GamepassTools?

Inside GamepassTools (folder) there is something called GamepassBike

If your scripts are exact duplicates… then the issue is either with the gamepass or the tool. Assuming you own the gamepass, I would then look at the tool and why its not cloning to the backpack. Does this tool have a handle?

Yes it does have handles. I’m still confused as I have three scripts, but yet all the others work besides this.

I dont mean handles as in handle bars, i mean a Handle, like in a tool. Your other tool is a gun… this is a bike. Something in your backpack has to be a tool, like the gun.

image

1 Like

Oh ok, so its a tool. Hmmm, and you own the gamepass?

Yes. I do, someone also else does.

Only thing I can think of is that the script isnt a server script, or is in the wrong location?

But it works for the others?
image

Yeah im stumped, sorry… its something im not seeing.

Are you receiving any errors in the devcolsole?

First off, in the secnd script, Lighting and toolsParent both refer to game.Workspace.GamepassTools, not sure why it is in there twice

edit both scripts actually