Accessed Non trying to read property on a widget variable even after creating it

Hi,
I’m new using Blueprint and I keep getting this runtime error with my script:

There is my blueprint script, called from the BeginPlay of my Level Blueprint. It is located on the Game Instance Class of my project.

Thank you

Looks like you aren’t using the correct player controller. This is probably an issue with the world settings for the level. And due to the incorrect controller you aren’t creating the widget properly so the variable is not valid when you try and add the menu widget to the viewport. Fix the controller issue and the other one will likely resolve.

Thanks for your reply. The issue seems to be this one.
It works if I uncheck the “Run dedicated server” but with this option I’m getting the error.
How can I fix this or know the index of the current player to select?

Dedicated servers are “headless” meaning that they have nothing to render to. Do a check if Dedicated or not, and only call this code if NOT a Dedicated server.