Hello,
I’m extremely tired so ill just post the script and the problem.
local TableOfNumbers = { -- Necessary
[1] = "One",
[2] = "Two",
[3] = "Three",
[4] = "Four",
[5] = "Five";
[6] = "Six";
[7] = "Seven";
[8] = "Eight";
[9] = "Nine";
[10] = "Zero";
}
local TableOfItems = { --Necessary
[1] = false,
[2] = false,
[3] = false,
[4] = false,
[5] = false;
[6] = false;
[7] = false;
[8] = false;
[9] = false;
[10] = false;
}
function IsToolInTable(tool)
for i, v in pairs(TableOfItems) do
if v == tool then
return true
end
end
return false
end
function AddTool(tool, choice)
if not IsToolInTable(tool) then
local availableIndex = 1
while TableOfItems[availableIndex] do
availableIndex = availableIndex + 1
end
TableOfItems[availableIndex] = tool
else
-- Allow duplicate tool through
return
end
end
plr.Backpack.ChildAdded:Connect(function(child)
if not child:FindFirstChild("AllowThroughBackpack") then
AddTool(child)
refreshGUI()
else
child:FindFirstChild("AllowThroughBackpack"):Remove()
refreshGUI()
end
end)
UIS.InputBegan:Connect(function(IP,GP)
if GP then return end
for i,tool in pairs(TableOfItems) do
if TableOfNumbers[i] then
if IP.KeyCode == Enum.KeyCode[TableOfNumbers[i]] then
if tool ~= nil or tool ~= false then
for i2,tool2 in pairs(plr.Backpack:GetChildren()) do
local chara = plr.Character:FindFirstChildWhichIsA("Tool")
print("true")
print(tool2)
if chara then
print("found a tool")
if chara == tool then
print("they are the same")
game.ReplicatedStorage.ServerEvent.BackpackEvent:FireServer(false)
break
else
game.ReplicatedStorage.ServerEvent.BackpackEvent:FireServer(true,tool)
end
else
game.ReplicatedStorage.ServerEvent.BackpackEvent:FireServer(true,tool)
break
end
end
break
end
end
end
end
end)
Whenever I equip a tool (that’s already in the starter pack), it works but then when i move that SAME tool from backpack2 to backpackmain, it doesn’t want to function.
So whenever you add a tool to THE MAIN BACKPACK, it doesnt work.
Dont question about the tools, the tools already work, even without the backpack script.
Theres another script which this is linked to but its mainly just Humanoid:Equiptool() ( WE SHALL CALL THIS EQUIPSCRIPT )
Here’s basically many ways that it doesnt want to work:
Error Number 1:
- Move tool from backpack2 to backpackmain
- It prints that the tool has been equipped. (EQUIPSCRIPT prints this)
- The tool is in the players inventory but it falls out the map anyways.
Error Number 2:
- A New tool is added (it does not share the same name with any other tool).
- It prints that the tool has been equipped. (EQUIPSCRIPT prints this)
- The tool is in the players inventory but it falls out the map anyways.
Error Number 3:
- A New tool is added and it shares the same name as another tool.
- It prints out nil has been equipped. (EQUIPSCRIPT prints this)
- The tool is not in the players inventory.
That’s all the errors that occur in this,
if you need more information dm me but i wont be online for at least 20 hours.
Please try and help me the best of your ability.