Humanoid:EquipTool() not working after player respawns

When the player first spawns, I click a button which calls the following code, it works as expected until the player dies and respawn, the module function runs and EquipTool is being called.

However, the tools are no longer being added to the player’s backpack.

I know that when you equip a tool it removes it from ReplicatedStorage, which is why I have cloned it.

function module:equipWeapons()
	humanoid:UnequipTools()
	player.Backpack:ClearAllChildren()
	for _, weapon in weaponData do
		local tool = ReplicatedStorage.Weapons[weapon.category][weapon.name].Tool[weapon.name]:Clone()
		humanoid:EquipTool(tool)
	end
end

Any help would be greatly appreciated.

I found the issue with the code, I had the following

local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character.Humanoid

located in the header of the module, when it should have been inside the function as I didn’t realize humanoid would no longer reference the player’s character’s humanoid.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.