I wanted to create a webpart using SharePoint solutions in visual studio 2015. I'm currently using sharepoint foundation 2013. I don't understand why I'm getting this error because it seems that I've already installed all the latest versions of software. Does anyone know how to solve this issue?
Your Visual Studio 2015 installation must be in your SharePoint server.
The SharePoint project templates that come with Visual Studio 2015 target SharePoint 2016. That's why you're getting this error. To build SharePoint farm solutions targeting SharePoint 2013, you need to use Visual Studio 2013.