Client pawn possession not working?

So I am trying to have a multiplayer game where there are 2 teams, Red and Gold. I am trying to have the client and server possess their own pawns, but it seems that the client version is not possessing the pawn. Here is my setup in the Level Blueprint. I want the server and client to be able to choose their pawn separately. Any help is appreciated.
Here is the server side of the possessing.

Here is the Client Side:

First, is bad practice to client demand something like that.

But aside, problem is in “get player controller (index 0)”.

When you RPC it to server, it getting local index 0 controller on server. What you need to do, is get reference to correct controller on server or create Input Variable Player Controller for your RPC server possess, “get player controller 0” on client and “send it” thru possess to server.

I created a variable and referenced it to my Player Controller and used it instead of the “get player controller” for the server. Then i used “get player controller” for the client, but it just brought up and error with the “Possess” node.

Use the “Event Post-Login” in your GameMode. It comes with a node that provides the already existing PlayerController for the player; you can just take it, spawn an actor, and have that controller possess it.

If for whatever reason you need to spawn a new pawn and give it to your playercontroller I suggest you take the above and turn it into a callable function named “Respawn” and have it get called in the beginning. Add a node in there that checks if “Controlled Pawn” “IsValid” ; if it’s not then spawn a pawn. If it is then either it was called by mistake, the pawn isn’t destroyed yet but will be soon (prevented by adding a .2s delay node in front of the isValid?), or the client is attempting to cheat.

Anyway, your PlayerController should have an “IsValid” at least once in every event before attempting to access its player character and if that player character isn’t valid call the Respawn function on the server. You may run into an issue where the PlayerController will call about 2 - 4 invalid frames worth of character lookups before it realizes it has a character but not a big deal; it can be resolved. Just remember to make calls like that only on the Server. The only thing your Client’s PlayerControlelr should be doing is taking inputs and giving them to your character. Other than that EVERYTHING is “Is Authority?” before doing anything.

Very tired and no reference in front of me so I’m sorry if that’s confusing; feel free to ask questions.

Okay that helped me a little bit, I moved it from the Level Blueprint to the GameMode and Controller Blueprints, but I am still having trouble. When I run 2 players, only one pawn is created. The server doesn’t possess the pawn but the Client will. Here is my Controller Blueprint:

And here is my Gamemode Blueprint:

There are… massive problems with what you’ve just done.

I’ll just attach a screenshot of what I have and I’m sure it’ll make sense.

So that function is in the Player Controller? And thank you for the help!

The function is in an Actor called “PlayerStats” that I made after I initially couldn’t get PlayerState to work. I think I can do that now but it’s a lot of work to convert it over that I’m not even sure would be worth it given that it’s all working now.

PlayerStats is created OnBeginPlay in my GameMode and is responsible for telling my controllers who their players are and whatnot.

This Respawn function used to exist in my GameMode but I thought it was causing a bug so I moved it over to PlayerStats. It had nothing to do with the bug but I was too lazy to move it back over given that it had no real implications.

Just remember to replicate variables! Nearly half of the bugs I’ve faced with networking is me simply forgetting to set a variable to replicate.

Okay I understand it now and got it working! Thank you for the help!

Thank you man! it was event “post login” that i needed! thanks.

Thank you Travistyse! Adding a 0.2 second delay between spawning the actor and possessing the actor solved the problem for me (in multiplayer–this issue didn’t even occur in single player). I was looking everywhere to solve this–checking that replication was correct, wondering if I setup my actor + camera together correctly…turned out I just needed a delay!