How to Pick Specific Thing from other Children?
Asked by
4 years ago Edited 4 years ago
So I made a zombie who moves to kill someone he finds and there are a lot of models like Torso and other body parts it was R6 and so I wanted to return its target name but I don't know from all the parts how to choose its name.
Look at return target at line 13 where it says "return Target"
01 | local ZombieTorso = script.Parent.Torso |
02 | local ZombieHum = script.Parent.Humanoid |
07 | for i,v in pairs (game.Workspace:GetChildren()) do |
08 | local Human = v:FindFirstChild( "Humanoid" ) |
09 | local Torso = v:FindFirstChild( "UpperTorso" ) |
11 | if Human and Torso and v ~ = script.Parent then |
12 | if (ZombieTorso.Position-Torso.Position).Magnitude < Distance then |
21 | local TargetIs = Move() |
24 | ZombieHum:MoveTo(ZombieTorso.Position + Vector 3. new(math.random(- 50 , 50 ), 0 )) |