Your iPhone might have restrictions enabled that prevent screen recording. Navigate to Settings > Screen Time > Content & Privacy Restrictions > Content Restrictions. Scroll down to Screen Recording and allow it if it isn't already enabled.