Making a will is not something that just anyone can do. There are a few things that need to be present and the first one is that you must have valid testamentary capacity. In simple terms, this means that not only do you need to be at least eighteen years old, you must be able to understand what making a will means.
You must understand all terms of a will, be aware of those you are benefiting in the will, have a rough idea of what you have to leave and being aware of those you have a moral obligation to. Even though you might be of unsound mind and possibly suffering from delusions, you can still make a will as long as that condition does not affect the previously mentions points.
If you become insane after making your will, this will not cause your will to become invalid. Even a normally incapable person can make a will while they are in a lucid period. As long as you had testamentary capacity at the time of making the will, it will be legal. Anyone in actual military service or a person who is a seaman at sea can be under the age of eighteen and still able to make an informal will.