Run this and show me what it prints please
local maxOnHotbar = 5
local Players = game:GetService("Players")
local StarterGui = game:GetService("StarterGui")
local UserInputService = game:GetService("UserInputService")
local p = Players.LocalPlayer
local Backpack = p.Backpack
local Character = p.Character
local KEYS = {One = 1, Two = 2, Three = 3, Four = 4, Five = 5}
local items = {}
local CurrentEquipt
local function handleEquip(tool)
if tool.Parent ~= Character then
Character.Humanoid:EquipTool(tool)
CurrentEquipt = tool
end
end
local function updateAdd(tool: Tool)
if not tool:IsA("Tool") then
return
end
local toolname = tool.Name
local tooltype = tool.ToolTip
if table.find(items, tool) then
return
end
local CurrentToolIndex = table.find(items,CurrentEquipt)
print(CurrentToolIndex)
table.remove(items,CurrentToolIndex)
--table.insert(items,tool,table.find)
end
local function updateRemove(tool)
if not tool:IsA("Tool") then
return
end
if tool.Parent == Character or tool.Parent == Backpack then
return
end
if table.find(items, tool) then
local index = table.find(items, tool)
table.remove(items, index)
end
end
while true do
local success, err = pcall(function()
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
end)
if success then
break
end
task.wait(1)
end
for _, tool in pairs(Backpack:GetChildren()) do
updateAdd(tool)
end
Backpack.ChildAdded:Connect(updateAdd)
Backpack.ChildRemoved:Connect(updateRemove)
Character.ChildAdded:Connect(updateAdd)
Character.ChildRemoved:Connect(updateRemove)
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then
return
end
if KEYS[input.KeyCode.Name] then
local index = KEYS[input.KeyCode.Name]
if items[index] then
handleEquip(items[index])
end
end
end)
Prints nil when It runs.
okay you can remove it now thanks
task.wait(5)
local MaxHotbarItems = 5
local KeyBinds = {One = "Primary", Two = "Secondary", Three = "Item1", Four = "Item2", Five = "Item3"}
local UserInputService = game:GetService('UserInputService')
local PlayerService = game:GetService("Players")
local Player = PlayerService.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Backpack = Player.Backpack
local WeaponHandler = game:GetService("ReplicatedStorage"):FindFirstChild("Remotes"):FindFirstChild('WeaponHandler')
local Using
local Items = {
["Primary"] = nil;
["Secondary"] = nil;
["Item1"] = nil;
["Item2"] = nil;
["Item3"] = nil;
}
local function WeaponEquip (Weapon)
if Weapon.Parent ~= Character then
Character.Humanoid:EquipTool(Weapon)
print(Using)
end
end
local function UnEquipTools ()
Character.Humanoid:UnequipTools()
end
local function WeaponFunction (Tool)
if Tool:IsA("Tool") then
local ToolName = Tool.Name
local ToolType = Tool.ToolTip
Items[ToolType] = Tool
end
end
WeaponHandler.Event:Connect(function(Tool,Value)
print(Tool)
end)
UserInputService.InputBegan:Connect(function(input,gameProcessed)
if gameProcessed then
return
end
if KeyBinds[input.KeyCode.Name] then
local WeaponIndexSelected = KeyBinds[input.KeyCode.Name]
Using = WeaponIndexSelected
if Items[WeaponIndexSelected] then
WeaponEquip(Items[WeaponIndexSelected])
end
end
end)
while true do
local success, err = pcall(function()
game:GetService('StarterGui'):SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
end)
if success then
break
end
task.wait()
print("Pending Gui Disable")
end
for _, tool in pairs(Backpack:GetChildren()) do
WeaponFunction(tool)
end
Backpack.ChildAdded:Connect(WeaponFunction)
Backpack.ChildRemoved:Connect(WeaponFunction)
3 Likes