Hey I wanna make it so that when I click a specific part it adds a tool to the players backpack, however I don't know how to tell the game to put it in the players backpack since I am getting an error. (The following code is part of a script inside of a tool)
The error: Workspace.Tool shop.Dumbell2.Script:7: attempt to index nil with 'Backpack'
My code:
local Player = game.Players.LocalPlayer
local PlayerHasTool = false
ClickDetector.MouseClick:Connect(function(playerWhoClicked: Player)
if PlayerHasTool == false then
game.ServerStorage.Dumbell2:Clone().Parent = Player.Backpack
PlayerHasTool = true
else
return
end
end)