EventBeginPlay replicates to all players without without being told to

I have multiple players in my game, and when ever i press a key on the keyboard, a weapon is changed to the player who pressed they key, and won’t replicate it to other players so only he will see it.
How ever, when starting the game i want the first weapon to be picked automatically ( just like you start with a pistol in every FPS ), but when i try to do it from EventBeginPlay, it acts like if i was multicasting the command to all clients and they all can see the weapon i’v just picked ( they see a floating gun mesh ) while if i press a key to replace pick a weapon they will see nothing.
Is that a bug ?

And if so, how do i tell it to run only in the current player?

I guess the way you use the replication tells every player to update every other client on their side. This results in everyone having the gun.

What you could do is using the PlayerControllers that the server knows. He is the only one who knows every controller. So you could iterate
through all the PlayerController on Begin Play and call your PickUpFunction through this (Switch has Authority comes in handy to prevent clients
from doing the same).

Thanks for the advice ! I will give it a try.

Update : Thank you very much eXi! Works great :slight_smile:

Update 2 : This solution works great when the game is on dedicated server.
If there is a player who hosted the game and he is playing as well, he will still affect the other clients, is there any way to deal with that ?

What exactly is he affecting?

Do all player see the weapon of the other players or is only the hosts weapon being replicated?

I hope someone else can give you advise, because i’m in the middle of learning for an exam
and i can’t concentrate on your problem right now. Sorry ):

Thanks for trying and good luck with the exam :slight_smile:
every player has a controller that hide the player mesh ( only for him, so it won’t obscured his view ) and also activate the “Pick a gun” ( witch is showing a gun in front of him ).
Every other player needs to not be affected and keep on seeing the player mention above as a character with no weapon.


yes that is your basic idea. My question is, what the listen server (client as host) is now doing wrong for you?
Normaly it you not make any difference using a dedicated server. Because the server (clienthost and/or dedicated)
just goes through his list of PlayerControllers (with a clienthost he will have his own PlayerController at 0) and
runs the function client side with the replicated function.

This is how the blueprints looks like:


And when there is a clienthost on the game, he will see all the other clients as floating gun ( like only he supposed to look to himself ) while all the other clients will see everything as it should be.

This is like the clienthost is working on all of the controllers instead of only on it’s controller.
How can i make him act like a client which is not an host ?

*Edit : Ok i’v solved it by changed the “Get possesed pawn” to “Get player character” on index 0.
So i guess now it iterates between all controller and works only on the one with character index 0…
I would really like to have a better and more neat solution :expressionless: