Need help getting an averaging multiplayer camera to work

i’m aware this has most likely been posted but i cannot find any info in regards to what i’m looking to do.

i have created a basic shared multiplayer cam, that track average player location and zooms in and out based on players relative distance to one another, however i’m having an issue with scaling it down for less players,

this is the bit i need to refine
at the moment on the begineventplay it gets all player controllers and sets these P1-4 based on player, but if i only have 1/2/3 players, or a player dies, it has nothing to reference for this so throws errors,

any ideas on how i could go about making this more dynamic?

thank you all