Personality and IQ are mainly genetic BUT both can be greatly changed by environmental variables.
For example, people with personality disorders often get it from their parents. (And not necessarily Disorder A gives child Disorder A but some work like A -> B -> A -> B etc) BUT if they were adopted to another family there is a decent chance they would break the cycle. Also personality can be changed such as a healthy normal type of personality could be changed by abuse as a child. Also environmental changes could be a depressed low energy person discovers a job that constantly engages them and rewards them in such a way they are not often depressed anymore. Their personality changed from the environment they put themselves into. A narcissist put into a position where they are obviously not the best at hardly anything will change them (its actually the only real way to cause a drastic change to a narcissist personality type).
IQ is mainly genetic but if a child grows up in an environment where IQ pattern recognition is not used they can lose potential IQ, bad diet can lose potential IQ, along with some other environmental factors. You can't gain IQ though like if your genetics give you a potential IQ of 120 max then you will be 120 or below, and that will be determined by environment.