EquipTool() not working

I’ve created a custom inventory script and am firing a event for the server to equip the tool. However when the event is fired this error is given.
image

The local script is shown below.

function CheckForSlotKey(KeyCode)
	local Check, Pos = IsInTable(SlotKeys, KeyCode)
	if Check then
		if CurrentTool then
			if Pos == 10 then
				Pos = 0
			end
			local TestSlot = HotbarItems["Slot".. Pos]
			if TestSlot == CurrentTool then
				REvent:FireServer("UnequipTools")
				CurrentTool = nil
			else
				REvent:FireServer("EquipTool", TestSlot)
				CurrentTool = TestSlot
			end
		else
			local Tool = HotbarItems["Slot".. Pos]
			REvent:FireServer("EquipTool", Tool) --Where the event is fired
			CurrentTool = Tool
		end
	end
end

This is the server script.

REvent.OnServerEvent:connect(function(...)
	local Inputs = {...}
	local Player = Inputs[1]
	local Cmd = Inputs[2]
	if Cmd == "EquipTool" then
		local Tool = Inputs[3]
		local Character = GetCharacter(Player)
		Character:WaitForChild("Humanoid"):EquipTool(Tool) --Where error is given
	elseif Cmd == "UnequipTools" then
		local Character = GetCharacter(Player)
		Character:WaitForChild("Humanoid"):UnequipTools()
	end
end)

I’ve even tried the simpler approach of changing its parent without using EquipTool() and it still gives the same error.

Issue solved. I was forgetting to update the Backpack variable after the character dies resulting in the script trying to pull tools from the old backpack when is locked to nil.

3 Likes