Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.93 KB | None | 0 0
  1. -- Variables
  2.  
  3. local head = script.Parent
  4.  
  5. local Body_Position = head.BodyPosition
  6.  
  7. local StudsAway =20
  8.  
  9. Body_Position.Position = head.CFrame.p
  10.  
  11. radius = script.Parent.Parent.radius
  12.  
  13. cooldown = 3 -- Cooldown
  14. cooldown2 = cooldown / 2
  15.  
  16. cd = cooldown - cooldown2
  17.  
  18. script.Parent.Parent.radius.Size = Vector3.new(0.1,StudsAway,StudsAway)
  19.  
  20. script.Parent.Parent.radius.Size = script.Parent.Parent.radius.Size + script.Parent.Parent.radius.Size
  21.  
  22. while wait() do
  23.  
  24.     zombie = game.workspace.Zombies:FindFirstChild("Zombie") --Find Enemy
  25.     if zombie ~=  nil then
  26.         health = zombie.Health.Value
  27.         local hitzone = zombie.green.Position - Vector3.new(zombie.green.Position.X,0,0)
  28.         local distance = (head.CFrame.p - zombie.green.CFrame.p).Magnitude
  29.            if distance <= StudsAway then
  30.             --Attack Enemy
  31.             script.Parent.Parent.PrimaryPart = head
  32.            script.Parent.Parent:SetPrimaryPartCFrame(CFrame.new(head.CFrame.p, zombie.hit.CFrame.p))
  33. script.Parent.Parent:SetPrimaryPartCFrame(CFrame.Angles(0, script.Parent.Parent.PrimaryPart.Orientation.Y/180*math.pi,  script.Parent.Parent.PrimaryPart.Orientation.Z/180*math.pi) + script.Parent.Parent.PrimaryPart.Position)
  34.         -----------------------
  35.        
  36.        
  37.         local parts = radius:GetTouchingParts()
  38.         table.insert(parts,2,"hi")
  39.        
  40.        
  41.        
  42.        
  43.        
  44.        
  45.        
  46.        
  47.        
  48.        
  49.        
  50.        
  51.         -----------------------
  52.        
  53.            health = health - 3 --damage
  54.            zombie.Health.Value = health
  55.            script.Parent.Parent.Gunfire.Transparency = 0.2
  56.            wait(cooldown2)
  57.            script.Parent.Parent.Gunfire.Transparency = 1
  58.            wait(cd)
  59.         end
  60.     else
  61.         --script.Parent.Parent:SetPrimaryPartCFrame(CFrame.new(head.CFrame.p, script.Parent.Look.CFrame.p))
  62.         script.Parent.Parent:SetPrimaryPartCFrame(CFrame.Angles(0, script.Parent.Parent.PrimaryPart.Orientation.Y/180*math.pi,  script.Parent.Parent.PrimaryPart.Orientation.Z/180*math.pi) + script.Parent.Parent.PrimaryPart.Position)
  63.        
  64.         wait()
  65. end
  66. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement