Spawn setup

So In my world Im planning to have multiple spawn points for players.
So that lets say that I have a string full of player display names.

when player joins, I want to check if their name is in the the array.
if it is, their spawn point would automatically be in the new spawn.
if their name isnt in the array, they just spawn in the default spawn.

this is the code Im using for testing purposes (this one doesnt have the condition yet):

public class Spawn_Test : UdonSharpBehaviour
{
[SerializeField] Transform Spawn, newSpawn;

public override void OnPlayerJoined(VRCPlayerApi player)
{
    if (player == Networking.LocalPlayer)
    {
        Spawn = newSpawn;
        player.Respawn();
    }
}

}

but the problem is that even without the condition, player spawns to the default spawn instead of the new position I setup before making them respawn.

Instead of player.Respawn, have you tried just teleporting them to that custom spawn point? i.e.

public class Spawn_Test : UdonSharpBehaviour
{
[SerializeField] Transform Spawn, newSpawn;
    public override void OnPlayerJoined(VRCPlayerApi player)
    {
        if (player == Networking.LocalPlayer)
        {
            Spawn = newSpawn;
            player.teleportTo(spawn);
        }
    }
}

As far as I can tell, the way to indicate where to respawn someone is to make OnRespawn teleport them to their custom spawn location. So you’d want to duplicate that into OnPlayerJoined, or even simply call OnRespawn(player).

thanks for the tip.
I will make sure to use this for my plans

so yeah after some testing with spawning having some conditions, it didnt work out.
however respawning worked perfectly.

so I can just go with the rejoining players that they have to respawn to get back into their rooms.

here is the code just in case anyone sees any problem with it.
ownerNames is an udon synced string array

public override void OnPlayerJoined(VRCPlayerApi player)
{
    if (player.isLocal && IsOwner())
    {
        player.TeleportTo(tpPoint.position, tpPoint.rotation);
    }
}

public bool IsOwner()
{
    foreach (var name in ownerNames)
    {
        if (Networking.LocalPlayer.displayName == name)
            return true;
    }
    return false;
}