Tools not working when equipping them from a script

I have a script in place that switches the item that you have equipped with the item that you have in your backpack. There are only 2 items in my game. The script itself works but the tools don’t work after they are switched out. For example, I have a gun that shoots normally when equipped from the Inventory, but when equipped from the switch script it stops working. Heres some of the code from the script :

local function FindTool(player)
	for i,v in pairs(player.Character:GetChildren()) do
		if v:IsA("Tool") then
			return v
		end
	end
	return false
end
local function FindBackpack(player)
	for i, v in pairs(player.Backpack:GetChildren()) do
		if v:IsA('Tool') then
			return v 
		end
	end
	return false
end
local function SwitchItem(player)
	local tool = FindTool(player)
	local back = FindBackpack(player)
	if tool and back then
		back.Parent = player.Character
		tool.Parent = player.Backpack
	end
end

Im pretty sure this isn’t a problem with my script though.

Don’t really need to set the parent of the tools. Use Humanoid:EquipTool and Humanoid:UnequipTools.