Trying to Assign a Team number to a player using a button

So what i am trying to do is when each player spawns in their team number is set to 0 or no team, in the map there are two buttons, each checks to see if the player is on a team, if not one button sets the team to 1 and the other button sets the team to 2. My problem is that once any player hits a team button, everyone is set to that team and they cant change.

This is my code, all of the functions are on the player controller which all players inherit upon joining

I might be because you are always changing the team variable on playercontroller 0,
rather than finding out the controller of the pawn that touches the button.

But that brings up another strange thing: Why are all the pawns referring to player controller 0?

player controller is the controller all characters inherit from, i have a character select thing, but all characters inherit from base character. what should i do instead of player controller

no, that is good. I mean player controller 0 is the player who has the keyboard and mouse, and who possessed one of the character pawns. So if you want to find out i formation about another character or make them do something, you should refer to that pawn or its controller, not player 0’s pawn or controller. otherwise it is like having lots of bodies but only one brain.

ok so how would you set it up to where every character starts off at variable int 0 for the team, then upon stepping on a button, change that var int to 1 or 2 for the teams for that specific player

I usually store things like which team the player is on, in their associated Player State.
So on Event Begin Overlap (in your Button), you can tell the Pawn that just stepped on you, to get their Player State, cast to your custom PLayer State class (so you can access the Team variable), and change the team var to 1 if it’s the one button, or 2 if it’s the other button.

Is this button its own class or is it just a thing you set up in the Level via level blueprint?

It is a class, i see what your saying, so i moved Team and IsOnATeam? to my player state, (PlayerInfo is what it is named), but how would i go with finding the characters value and setting it.

Also i have a player save game that saves the PlayerInfo to a file that reads upon opening. The player info carries the players name and image from game to game and lobby to lobby, just a notice as when the player sets the team, that team number is engraved in the file now

when the button receives onoverlap event i think there is a wire you can pull out to get the actor that overlapped it. Cast that actor to pawn and then get the playerstate from that pawn then set the team vars on the playerstate

you made me think of something and so i tried it, my default pawn set in my gamemode is 0_Base so i set certain variables in that, while also settings other variables from my gamemode itself, teams work technically now, just gotta fix the spawning bug now, should i post what i did

ok teams work now, but now new bugs have came about, my money value at the top of the screen was stored in the player controller, now its stored in the gamemode, in doing this change the money only shows for the server and not the client, another bug now is the items payed for, only spawn in the map for the server

Are the items paid for set to Replicate?

Also GameMode only exists on Server, not on clients as far as I know (however, GameState is replicated to clients and it can be since it is an Actor).

yes they are set to replicate, but could it be because im casting to the gamemode in the scripts that it is only happening on the server. Which would be the best place to store the money value so that it shows perfectly on the both server and clients and that might fix a big issue