Before getting into soloing you need to know some basic principles of harmony and theory.
So you know what scales are compatible to a given chord progression.
The other main element is Technique, to add expression and style.
When you get to that point, you will be ready to improvise.
Bottom line, improvising is not just playing anything, there is a logic behind that aproach.