The designated player joins the designated team||doc135776

September 20, 2022

Format

 Game.TryJoinTeamByPlayer(player, teamId) 
  • The class to which the function belongs:Game

Description

Attempt to join the team with the specified team ID.


Value Returned

type Description
boolean whether succeed
string Reason for failure


Parameters

Variable name type Description
player Player player
teamId int team id


Code Samples

On the server side of the entity templatemount script, add the registration of this type of entity when logging into the gameCallback,, try to join the team with team ID 1

Trigger.RegisterHandler(this:cfg(), "ENTITY_ENTER", function(context)
    local player = context.obj1
    local ret, msg = Game.TryJoinTeamByPlayer(player, 1)
    print(ret,msg)
end)