Visual studio doesn't open scripts

i’m trying to work on a 2019 unity project but when i try to edit scripts on microsoft visual studio it says it’s not compatible (that it wasn’t created for visual studio tools for unity) and to set preferences selecting visual studio (already done it). Is it because i have Visual Studio 2022? what can i do to fix this? Thanks!