Because six students don't take part in any sports, there are 30-6 =24 students who take part in sports, of which 12 plays tennis and 16 plays squash. Then:
1) Students who play tennis and squash = 12+ 16-24 =4.
2) Students who only play tennis = 12-4=8.
3) Students who only play squash = 16-4= 12.