Advertisement
Guest User

Untitled

a guest
Jul 20th, 2018
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.43 KB | None | 0 0
  1. function Zombie:GetClosestTarget()
  2.     local Target = self.Target
  3.     for _, Player in next, Players:GetPlayers() do
  4.         local Torso = Player.Character:FindFirstChild("Torso")
  5.         local Distance = (self.Root.Position - Torso.Position).magnitude
  6.         if Target then
  7.             if Distance < (self.Root.Position - Torso.Position).magnitude then
  8.                 Target = Player.Character
  9.             end
  10.         else
  11.             Target = Player.Character
  12.         end
  13.     end
  14.     self.Target = Target
  15. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement