I sprained my ankle a month ago my ankle is still a little swollen and I still get pretty bad pain but I was able to walk same day should I get a xray?

Get it looked at. If you are 4 weeks out from your injury it should be feeling better. Sprains can take 6-8 weeks to heal, make sure you are doing range of motion exercises daily. But if you are still getting swelling and bad pain you could have injured the ligaments around the ankle which would need to be evaluated by a doctor. .