--		Humanoid:UnequipTools()
--		if tool then
--			Humanoid:EquipTool(tool)
--		end

		for i,v in pairs(Char:GetChildren()) do
			if v:IsA('Tool') then
				v.Parent = Backpack
			end
		end
		if tool then
			tool.Parent = Char
			tool.Unequipped:connect(function()
				wait()
				EquippedVal.Value = getSlotFromTool(Char:FindFirstChildOfClass('Tool'))
				--EquippedVal.Value = nil
			end)
		end
		
		if tool == nil then
			EquippedVal.Value = nil
		end
	end
	
	-- Takes Enum.KeyCode and gets string at end
	local function getKeyCodeName(keycode)
		keycode = tostring(keycode)
		local splitStrings = string.split(keycode,'.')
		return splitStrings[#splitStrings]
	end
	
	-- Equips whatever the Equipped Obj's value is
	EquippedVal.Changed:Connect(function()
		local equipSlot = EquippedVal.Value
		if equipSlot then
			equip(equipSlot.Value)
		else
			equip(nil)
		end
	end)
	
	-- ensure equipped items replicate when changed
	for i,v in pairs(SlotsFolder:GetChildren()) do
		v.Changed:connect(function()
			if EquippedVal.Value == v then
				wait() -- required to prevent slot duping
				equip(v.Value)
			end
		end)
	end
	
	-- Checks keyboard input
	UserInputService.InputBegan:Connect(function(input, gameProcessed)
		if not gameProcessed then -- Ensures user is not typing in TextBox
			-- Ensures user is using keybooard
			if input.UserInputType == Enum.UserInputType.Keyboard then
				-- Get the KeyCode and KeyCode's ending/name
				local keyPressed = input.KeyCode
				keyPressed = getKeyCodeName(keyPressed)
				-- Checks if there is a slot w/ the pressed key's name
				local slotRequested = SlotsFolder:FindFirstChild(keyPressed)
				if slotRequested then -- if there is such a slot
					-- if they're requesting the same slot
					if EquippedVal.Value == slotRequested then 
						EquippedVal.Value = nil -- unequip the tool
					else
						EquippedVal.Value = slotRequested -- equip the tool
					end
				end
			end
		end
	end)
	
	return EquippedVal
end


