AllowTeamChangeOnTouch (Property): Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>Anaminus
m AllowTeamChangeOnTouch moved to AllowTeamChangeOnTouch (Property)
m Text replacement - "<SyntaxHighlight code="lua">" to "<syntaxhighlight lang="lua">"
Tags: mobile web edit mobile edit
 
(20 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{Property|
{{CatUp|Properties}}
name                 = AllowTeamChangeOnTouch
 
|property             = [[Bool]] ''AllowTeamChangeOnTouch''
<onlyinclude>{{Property
|description         = When enabled, allows the player that touched the object to join the object's team.
|name = AllowTeamChangeOnTouch
|object               = [[RBX.Lua.SpawnLocation (Object)|SpawnLocation]]
|property = [[Bool]] ''AllowTeamChangeOnTouch''
|}}
|description = When enabled, allows the player that touched the object to join the object's team.
|object = SpawnLocation
}}</onlyinclude>
 
{{clear floats}}
 
[[Category:Properties]]
 
{{Example|<syntaxhighlight lang="lua">
local bools = { false, true }
local teams = game:GetService( "Teams" ):GetTeams()
 
function change_AllowTeamChangeOnTouch( otherPart, spawn )
  if game.Players:GetPlayerFromCharacter( otherPart.Parent ) then
      spawn.AllowTeamChangeOnTouch = bools[ math.random( 1, 2 ) ]
  end
end
 
for i = 1, 15 do
  local spawn = Instance.new( "SpawnLocation", Workspace )
  spawn.Neutral = false
  spawn.TeamColor = teams[ math.random( 1, #teams ) ]
  spawn.Touched:connect( function( otherPart ) change_AllowTeamChangeOnTouch( otherPart, spawn ) end )
end</syntaxhighlight>}}

Latest revision as of 06:15, 27 April 2023

AllowTeamChangeOnTouch
Property Bool AllowTeamChangeOnTouch
Description When enabled, allows the player that touched the object to join the object's team.
Member of SpawnLocation
Example
local bools = { false, true }
local teams = game:GetService( "Teams" ):GetTeams()

function change_AllowTeamChangeOnTouch( otherPart, spawn )
   if game.Players:GetPlayerFromCharacter( otherPart.Parent ) then
      spawn.AllowTeamChangeOnTouch = bools[ math.random( 1, 2 ) ]
   end
end

for i = 1, 15 do
   local spawn = Instance.new( "SpawnLocation", Workspace )
   spawn.Neutral = false
   spawn.TeamColor = teams[ math.random( 1, #teams ) ]
   spawn.Touched:connect( function( otherPart ) change_AllowTeamChangeOnTouch( otherPart, spawn ) end )
end