Dear Carly, this is a very good question.
We cannot see the center of the Sun directly, but we understand the composition of the Sun and how gravity works. Knowing the laws of physics that tell us about gravity, and about what happens to atoms under extreme conditions of pressure and temperature, we can construct computer models that tell us what the Sun is like in the center. We compare the predictions of these computer models with the observable part of the Sun, the data we get from the Sun's surface, to check whether our model of the solar interior is correct. We also use special instruments that detect solar oscillations, or internal earthquake-like movements of the gases in the Sun, and these waves give us information of the internal core structure.
Isabel Hawkins