Touchscreen.current.primaryTouch throwing NullReferenceException upon "Play"

I have a few instances in my code where I am trying to check if the screen is pressed. When I press Play, it throws a NullReferenceException for the following line:

if( !Touchscreen.current.primaryTouch.press.isPressed )

I am not sure if/how I need to initialize this Touchscreen class. I cannot remember which tutorial I found on Udemy but they wrote out the code to check just like the above and their code worked. Not sure if I missed installing something else.

I have the InputSystem package installed.

I apologize if the information above is not helpful. I am very much a beginner and am not sure what other information to include, but if you ask I will gladly provide screenshots.

Thank you!

We have no idea what hardware you're running on.

Null Reference is always the same process. Figure out what EXACTLY is null, and then make sure it isn't.

You have three different things that could be null in that one line of code. Whenever you stack things together in one line, it shows you're supremely confident that you know what you're doing, just like stacking four ladders on top of each other to reach the roof.

Is Touchscreen.current null?

Is Touchscreen.current.primaryTouch null?

Is Touchscreen.current.primaryTouch.press null?

Break it down.

My guess is Touchscreen.current is null, unless you happen to be running the code on a device with a supported touch system. But you should debug things to find out EXACTLY what is null.

https://www.youtube.com/watch?v=ERAN5KBy2Gs