Why won't the player's backpack autoequip by clicking a gui?
I'm trying to make the player, whenever he/she clicks a gui button, equip a tool from the player's backpack. It says it keeps failing at line 15. The error is listed below. Can someone explain to me why it is giving me an error? (Yes, it is in a LocalScript.)
Error: Players.Player1.PlayerGui.Backpack.ScrollingFrame.AutoEquip:15: attempt to index global 'findval' (a nil value)
01 | game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false ) |
03 | local player = game.Players.LocalPlayer |
04 | local character = player.Character |
05 | local tool = player.Backpack:GetChildren() |
07 | val = script.Parent.EquipedItem.Value |
08 | findval = player.Backpack:FindFirstChild(val) |
11 | findval:Clone().Parent = character |
21 | elseif val = = "Sword" then |