game:GetService('StarterGui'):SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
--< variables >--
local uis = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local char = workspace:WaitForChild(player.Name) -- added WaitForChild
local bp = player.Backpack
local hum = char:WaitForChild("Humanoid")
local frame = script.Parent
local template = frame.Template
local equipped = Color3.fromRGB(255,0,50) -- icon transparencies
local unequipped = Color3.fromRGB(47,47,47)
local inputKeys = { -- dictionary for effective referencing
["One"] =
{txt = "1"},
{img = "rbxassetid://6023987358"},
["Two"] =
{txt = "2"},
{img = "rbxassetid://6024209316"},
["Three"] =
{txt = "3"},
{img = "rbxassetid://6023987116"},
["Four"] =
{txt = "4"},
{img = "rbxassetid://6023986983"},
["Five"] =
{txt = "5"},
{img = "rbxassetid://6023986887"},
["Six"] =
{txt = "6"},
{img = "rbxassetid://6023986784"},
["Seven"] =
{txt = "7"},
{img = "rbxassetid://6023986695"},
["Eight"] =
{txt = "8"},
{img = "rbxassetid://6023986621"},
["Nine"] =
{txt = "9"},
{img = "rbxassetid://6023986521"},
["Zero"] =
{txt = "0"},
{img = "rbxassetid://6023987470"}
}
local inputOrder = { -- array for storing the order of the keys
inputKeys["One"],inputKeys["Two"],inputKeys["Three"],inputKeys["Four"],inputKeys["Five"],
inputKeys["Six"],inputKeys["Seven"],inputKeys["Eight"],inputKeys["Nine"],inputKeys["Zero"],
}
--< functions >--
function handleEquip(tool)
if tool then
if tool.Parent ~= char then
hum:EquipTool(tool)
else
hum:UnequipTools()
end
end
end
function create() -- creates all the icons at once (and will only run once)
for i = 1, #inputOrder do
local value = inputOrder[i]
local clone = template:Clone()
clone.Parent = frame
clone.Number.Image = value["img"]
clone.Name = value["txt"]
clone.Visible = true
clone.BackgroundColor3 = unequipped
local tool = value["tool"]
if tool then
clone.ToolImage.Image = tool.TextureId
end
clone.Tool.MouseButton1Down:Connect(function() -- click icon to equip/unequip
for key, value in pairs(inputKeys) do
if value["txt"] == clone.Name then
handleEquip(value["tool"])
end
end
end)
end
template:Destroy()
end
Pretty straightforward hotbar script that I found on toolbox and rescripted some of it, however, for some reason on function create() it prints Argument 1 Missing or nil
The error is that for some reason, the clone doesn’t get named with the create() function.
I don’t really know the reason, any help would be appreciated.
Thank you for reading ![]()