You have to be holding F while triggering this script for it to work.

It does not wait for the player to press F, it just checks if the player, at that moment, is pressing F.