Hello,
i've recently been working on my first game and created an inventory system in it. I have one major problem though and its that it wont take a tool from the inventory and place it in your backpack.
local player = game.Players.LocalPlayer
local playerInv = game.Players.LocalPlayer:WaitForChild("SpellList")
local backpack = player.Backpack:GetChildren()
local itemName = script.Parent.Parent.ItemName
local itemToCheck = player.SpellList:FindFirstChild(itemName.Value)
if itemToCheck then
local itemToEquip = player.SpellList:WaitForChild(itemName.Value)
local itemInBP = backpack:FindFirstChild(itemName.Value)
if #backpack < 2 and not itemInBP then
local equipToBP = itemToEquip:Clone()
equipToBP.Parent = player.Backpack
elseif #backpack >= 2 then
print("Unequip an item!")
elseif itemInBP then
itemInBP:Destroy()
end
end
inside of the gui that i created for the items there is a string value that gets changed to the tool's name so that i can use FindFirstChild() to search for whatever the tools name is in their inventory folder named "SpellList". The console isn't spitting out any errors and when i click the equip button nothing happens. the itemInBP and #backpack are to check if the player has more than 2 items equipped and if they already have the item equipped.

2 comments
thanks for the answer, i actually just forgot to put script.Parent.Mouse1ButtonClick:Connect(function()
Alright, glad you fixed it