Tool Not Getting Parented

I’m making a gamepass tool giver, but the problem is that the tool is not getting parented to the player’s Backpack, the “aa” was printed but the tool didn’t get parented, I even tried resetting but it still didn’t do anything but print “aa”.

local serverStorage = game:GetService("ServerStorage")

local tool = {
    {7681339, "Gun"}
}

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(char)
        for i = 1, #tool do
            local gamepassId = tool[i][1]
            local toolname = tool[i][2]
            if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, gamepassId) then
                print("aa")
                serverStorage:WaitForChild(toolname):Clone().Parent = player.Backpack
            else
                print("a")
            end
        end
    end)
end)
2 Likes

I believe this is a typo on spelling. Server Storage should be capitalized.
serverStorage:WaitForChild(toolname):Clone().Parent = player.Backpack
Should be:
ServerStorage:WaitForChild(toolname):Clone().Parent = player.Backpack

I had it defined at the top as serverStorage, so I don’t really think that’s the problem.

When you reference something like that, you need to make sure it’s capital. If not, the code will find something that doesn’t exist.

Change your line to my line and tell me the results.

I defined serverStorage as that exact capitalization. And also, tried out what you said, still didn’t work.

Oh my god, I just found out why. It’s serverStorage.Guns.Guns instead of what I wrote, my bad my bad.

No worries man, I figured it was some spelling mistake. Have a good christmas :smiley:

You too, thank you for responding!

Hey, no problem! Thanks for posting your code here. We’re here to help :slight_smile:

1 Like