Sinking Through Moving Platforms

I’m working on a game for a class.

The third level has platforms that move vertically, but shortly after the player character steps on them, he sinks through them while they’re moving up. Does anyone have an idea of how to keep him from sinking through?