Straight up depends on what you’re playing, the resolution & refresh rate of your monitor and whether you intend on midlife cycle upgrades or replacing it entirely in 5-6 years or so. AM5 will have support until 2029 with Zen6 and Potentially beyond — at least until DDR6 becomes mainstream.
If you’re tight on cash and willing to max out at a 5800x3d until like 2031 before building a whole new system (might be pretty expensive) then it makes sense to go with the AM4 build. Cash in-hand now is better than cash later.
Alternatively, you could invest upfront and have sizable drop-in upgrade later for much less (at that point) while having better performance upfront and in the immediately future. Personally I stomached the cost to get on AM5 because a PC is an investment, not something to cheap out on when you’re already putting in at least $1k.