new players||doc135784

September 20, 2022

Format

 Team:joinEntity(entity) 
  • The class to which the function belongs:Team

Description

Add the entity object to the team.


Precautions

  • Before the entity object joins the team, make sure that the entity object is not currently in any team, otherwise there will be an error.

Parameters

Variable name type Description
entity Entity entity object


Code Samples

Add the entity object whose object id is 1 to the team whose team id is 1.

local entity = World.CurWorld:getObject(1)
local team = Game.GetTeam(1, true)
if entity:getValue("teamId") ~= 0 then
    local oldTeam = Game.GetTeam(entity:getValue("teamId"))
    oldTeam:leaveEntity(entity)
end
team:joinEntity(entity)