Selling fangames is plenty legal so long as you don't infringe on IP.
This is technically correct, but considering the game doesn't reuse Undertale assets, unless Toby filed a gameplay patent there's not much to worry about.