Hi. I tried making a toolbar but for some reason, it didn't add the tool. In line 63, it's not changing nil to a tool or printing. Also, no errors in the output
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack,false)
-- Tables and vars
local num = {
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
}
local numinwords = {
'One',
'Two',
'Three',
'Four',
'Five',
'Six',
'Seven',
'Eight',
'Nine',
}
local tools = {
One = nil ,
Two = nil ,
Three = nil ,
Four = nil ,
Five = nil ,
Six = nil ,
Seven = nil ,
Eight = nil ,
Nine = nil ,
}
local uis = game:GetService('UserInputService')
local plr = game.Players.LocalPlayer
local backpack = game.Players.LocalPlayer:WaitForChild('Backpack')
local frame = script.Parent
local char = plr.Character
for i, v in pairs(backpack:GetChildren()) do
tools[i] = v
end
--Events
backpack.ChildAdded:Connect(function(tool)
print('ok')
for i, v in pairs(tools) do
if v == nil then
print('ok2') -- It's not printing 'ok2'
v = tool
end
end
for i, v in pairs(tools) do
print(tostring(v))
end
end)
backpack.ChildRemoved:Connect(function(tool)
print('ok')
for i, v in pairs(tools) do
if v == tool then
v = nil -- It's not changing it to nil when removed
end
end
for i, v in pairs(tools) do
print(tostring(v))
end
end)
for i, v in pairs(frame:GetChildren()) do
if v:IsA('ImageButton') then
print('ok')
uis.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode[v.Name] then
print('ok')
if tools[v.Name] ~= nil then
char.Humanoid:UnequipTool()
char.Humanoid:EquipTool(tools[v.Name])
end
end
end)
end
end
for i, v in pairs(frame:GetChildren()) do
if v:IsA('ImageButton') then
v.MouseButton1Click:Connect(function()
if tools[v.Name] ~= nil then
char.Humanoid:UnequipTool()
char.Humanoid:EquipTool(tools[v.Name])
end
end)
end
end
Any help/suggestion is appreciated.

2 comments
Thanks and i just realise i also forgot to use 'break
For the last part about print, I think that's incorrect. I've had some problems where it tries to print an instance so I have to use tostring().