Assigning Team Number

Im trying to assign a number 0(blue) and 1(red) to players who join and changing the material color based on the number given but I seem to have a problem with how variable replication works as the variable only recognizes the last value change in a frame so a fix to this would be appreciated.

You are assigning both numbers in one call. So only the last call will be the newest (which would be “1”).
You need a logic with which the PostLogin can decide which Team the Player should join.

Otherwise you will aways set the variable to 1.

In your OnRep function, you could also use “Controlled Pawn”, instead of “GetPlayerCharacter0”. But that is no real issue. Although i would recommend you to use an “IsValid” node for the PlayerCharacter. If the Controller is not yet controlling anything, you will get an “Access Violation” error.

PostLogin gets called when the Player has a valid PlayerController. This does not ensure that he also has an already spawned Pawn!

Could you help me out with the logic bit. Been trying all day but to no avail.

Thats not rly possible. This highly depends on your game.

The logic could be, that you have a Team Selection screen when someone joins (CounterStrike like). Or a lobby where you select the Team before the game starts. Or you could just put them randomly to 1 or 2.

Im trying to assign them so that
Player 1 is 0
Player 2 is 1
Player 3 is 0
Player 4 is 1

Although I suppose a Team Selection screen would be easier.

For something like the first solution, you just need to count an int up from 1 and use MODULO 2 on it each time. So every even number will put a player in one team and every odd number will put him into the other team.

Im not quite sure where to update TeamNumber to 1, I can’t do it on GameMode,MyPlayerController, or ThirdPersonCharacter since it immediately overrides the First Player’s Mesh Color once I do it.