I’m having a technical difficulty here. I’m attempting to force a player to join the “Spectators” team before their characters load up and spawns into the game. Reason being is because the spawns aren’t neutral and the players will usually spawn in the middle of the baseplate instead of the Spectator spawns.
players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(Character)
spawnAsSpectator:FireClient(player);
print("TEST");
end)
print("TEST2");
player:LoadCharacter() -- Spawn player character after to guarantee they will spawn as a Spectator
end)
In the above example, “TEST2” will execute first before “TEST” ever does, so I know that player:LoadCharacter() is being executed before the player.CharacterAdded:Connect(function(Character) function.
Is there a way around this or do I have to implement it another way?
Not sure why you have a remote event but you don’t need to fire the client to update a players team.
players.PlayerAdded:Connect(function(player)
player.Team = game:GetService("Teams").Spectators
player:LoadCharacter() -- Spawn player character after to guarantee they will spawn as a Spectator
end)
Or you could simply make the spectator team auto assignable. Its a property of the team object.
For some reason, “TEST2” still happens to execute before “TEST” does. Is there a way to tell the game to wait until the Remote Event is fired before calling player:LoadCharacter()?
It’s just the way my game works. I’m making a game where the server tells the clients what teams to choose and where to spawn, etc.
I also tried making the spectator team auto-assignable, however, my character is still getting spawned out in the middle of the baseplate instead of the Spectator spawns. Only when I reset my character (in-game) will it spawn me onto a Spectator spawn.
game.Players.CharacterAutoLoads = false
players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(Character)
spawnAsSpectator:FireClient(player);
print("TEST");
end)
print("TEST2");
player:LoadCharacter() -- Spawn player character after to guarantee they will spawn as a Spectator
end)
first, the player joins
then there is a function that activates when a character is added (function does not trigger)
then there is a print (TEST2)
last there is load character
this will trigger the Function
the function will print (Test)
“Is there a way to tell the game to wait until the Remote Event is fired before calling player:LoadCharacter()?”