Hi, I am making a multiplayer game and have blueprints in event end play on the first person character to let the server know you have disconnected and save your data, etc… The player state returns none when it is accessed after event end play. Does anyone know a potential fix for this?
Sure, this is what I want to run when a player disconnects. It is not optimized and I am planning to redo it, but use of the player state will be required so this is still an issue. The only relevant screenshot is the first one and the last one I think, because that is where I get the player state.
The error occurs at the start when I try to get the player state, the error is as follows (From a packaged dedicated server when a player disconnects):
This event is on the first person character event graph and I think that making the cast into impure will not fix the issue as the player state does not exist when this event is called. Would moving the event to the player state help to resolve the issue?
That would be a good idea. It would appear that the character is deleted after the PlayerState.
If possible, it would be best for whatever is destroying the PlayerState to call a save function on it before attempting to destroy it, that way you can ensure all relevant data is still available when you do.
However, if you can guarantee that the PlayerState is getting deleted first, you should be fine.
Try using the success pin with a branch to check if it’s valid before continuing the rest of that script. I was not aware that there were implicit cast nodes. You might not be casting it properly.
Anyways, if the player state is trying to reference itself before getting deleted, it would be strange that it’s returning null. Is this event on the player state itself?