Outertale is basically Undertale in space and well... Aftertale is actually a lot more complicated so I'll just link the Aftertale Comic Dub here. It actually builds up to the story of Fatal Error Sans. https://www.youtube.com/watch?v=3Hp5PxkVtH0&list=PLn2SZvHRmP_zaT5hlwFW7Z35OSwY1S5BX
Okay so basically Sans injected himself with Determination to hijack the resets and has the memory from other alternates Sans AUs and is stuck in the void with Frisk. He eventually becomes Fatal Error Sans but that's a tale for another time.