Help! Player window showing too many players when client connects to server

Not too sure what I’m missing, but I have a feeling it’s coming from the Forloops…When I start a multiplayer game on my server-side, a single player name pops up exactly how it should. But when the client-side connects, 3 players are shown as connected! The max is 4 players, yet no matter how many slots I specify, I get those 3 added names. Any Ideas?

Gamemode

to the player controller

to the lobby widget menu

Results…

when client connects

In the ‘update server’ code, your second for loop is on the first for loop. It needs to be connected to the Completed pin…

Thank you for your help, but unfortunately, that didn’t change anything. It still shows 3 extra clients.

Can you show the BP now?

To be clear, like this:

you don’t need that second forLoop at all, just continue from your CastNode. Why does your client list on the client shows “3” in the Player List but you have 4 Elements in the container? Can you please set a breakpoint before calling addPlayerToTheList to debug the arrayCount and please show how you collect the PControllers?

That’s exactly how I did it. but it’s still showing 3 clients connecting instead of just one.

I did what you said and bypassed the second forloop completely. Things still look great when the server side connects, but when the client side connects, it still only shows one player name, and it changes from the host name(yellow) to the client name (white) only. really strange.

That’s one of the biggest issues i’m having. you can set a max player count from 2-4 players, but no matter what, 3 clients show up. even when i play the game between the server and client, it all looks great, the player window itself is just adding the 2 extra client names for some reason.

really strange - but can you “…please set a breakpoint before calling addPlayerToTheList to debug the arrayCount and please show how you collect the PControllers?”
Best way to find such bugs is breakpoints and printstrings :wink:

Do your launch settings specify more than one player (dropdown under the Play In Editor button)?

I’m sorry, i’m still noobish with blueprints, but i’m getting there. how would i apply a “breakpoint”? is that the forloop with break?

it’s only set to two players. when the one client hopes on the server, 3 client side names appear. it should only be one.

Looks like you have a foreach loop inside of a foreach loop. Using the same array in each.
That means the inside one is going to execute once for every array entry in the inside loop, once, and then again and again until it has looped through the array completely as many times as there are in the outside loop. So that would be the length of All Players PCs times itself.

Thank you, everyone, for your help. I figured it out. I had another area in my gamemode where I was essentially doing the same “call all players and update window” twice. I removed the unneeded one, and it’s working perfectly. Thanks for the pointers!