Debbie, I get them when I get up from a recliner. I used to get that Frankenstein walk when I got up from bed, I don't get it anymore.
I shower before bed, then when the bathroom is warm (not hot) and my muscles are loose, I
hold onto the sink and stand on one foot and swing the other foot back and forth slowly. I think It stretches out the muscles, the ones that tighten during the day.
Then warm blankets because it's cold here and we keep the heat low to sleep. But the muscles don't pull in bed, like in a recliner during the day. It's weird.
I wear leg warmers on my legs (like the dancers wear) to keep my legs warm during the day. It makes a big difference in the way my legs feel. When chilled the top of the thigh muscle pulls. I take no medication for this. Just do stretching exercises routinely increasing the reps every few days.
When I relapsed, I could not even do one leg stretch without losing my balance, even holding on. Now I am up to my original routine, since the relapse is gone a month now.
Warmth is important, but don't overheat or overdo. Maybe some of this might help.

Start with two a night, swing the leg forward and in the same motion to the back, like a swing. Hold on to something firm, like a counter. You will feel the pull.