Mryeetmemes

CoreGeneral

Dec 9th, 2021
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.08 KB | None | 0 0
  1. local Players = game:GetService("Players")
  2. local Workspace = game:GetService("Workspace")
  3. local ReplicatedFirst = game:GetService("ReplicatedFirst")
  4. local ReplicatedStorage = game:GetService("ReplicatedStorage"):WaitForChild("ReplicatedStorage_CLOUD")
  5.  
  6. local Script = script
  7. local Model = script.Parent
  8.  
  9. local Torso = Model:WaitForChild("Torso")
  10. local Head = Model:WaitForChild("Head")
  11. local Humanoid = Model:WaitForChild("Humanoid")
  12.  
  13. local Handle = Model:WaitForChild("Handle")
  14. local Output = Handle:WaitForChild("Output")
  15. local Input = Handle:WaitForChild("Input")
  16. local Rocket = Handle:WaitForChild("Rocket")
  17.  
  18. local Configuration = Model:WaitForChild("Configuration")
  19. local _Damage = Configuration:WaitForChild("Damage")
  20. local _Range = Configuration:WaitForChild("Range")
  21. local _Can = Configuration:WaitForChild("Can")
  22. local _ReloadTime = Configuration:WaitForChild("ReloadTime")
  23.  
  24. local Enemies = Workspace:WaitForChild("Enemy")
  25. local NearbyEnemies = {}
  26.  
  27. function awardPlayers()
  28.     for _, v in pairs(Players:GetChildren()) do
  29.         if v:FindFirstChild("leaderstats") then
  30.             if v["leaderstats"]:FindFirstChild("Money") then
  31.                 v["leaderstats"]["Money"].Value = v["leaderstats"]["Money"].Value + 1
  32.             end
  33.         end
  34.     end
  35. end
  36.  
  37. function lookAtTarget(Target)
  38.     if Target then
  39.         Torso.CFrame = CFrame.new(Torso.Position, Vector3.new(Target["Torso"].Position.X, Torso.Position.Y, Target["Torso"].Position.Z))
  40.     end
  41. end
  42.  
  43. function shootTarget(Target)
  44.     spawn(function()
  45.         if _Can.Value == true then
  46.             _Can.Value = false
  47.             spawn(function()
  48.                 Output["FireSound"]:Play()
  49.                 wait(0.25)
  50.                 Output["ExplosionSound"]:Play()
  51.             end)
  52.             spawn(function()
  53.                 Rocket.Transparency = 1
  54.                 wait(0.25)
  55.                 Rocket.Transparency = 0
  56.             end)
  57.             spawn(function()
  58.                 Input["1FlashFX[Smoke]"].Enabled = true
  59.                 Input["FlashFX[Flash]"].Enabled = true
  60.                 wait(0.15)
  61.                 Input["1FlashFX[Smoke]"].Enabled = false
  62.                 Input["FlashFX[Flash]"].Enabled = false
  63.             end)
  64.             spawn(function()
  65.                 Output["1FlashFX[Smoke]"].Enabled = true
  66.                 Output["FlashFX[Flash]"].Enabled = true
  67.                 Output["FlashFX[Light]"].Enabled = true
  68.                 wait(0.08)
  69.                 Output["1FlashFX[Smoke]"].Enabled = false
  70.                 Output["FlashFX[Flash]"].Enabled = false
  71.                 Output["FlashFX[Light]"].Enabled = false
  72.             end)
  73.             spawn(function()
  74.                 if Target:FindFirstChild("Humanoid") then
  75.                     Target.Humanoid:TakeDamage(_Damage.Value)
  76.                 end
  77.             end)
  78.             awardPlayers()
  79.             wait(_ReloadTime.Value)
  80.             _Can.Value = true
  81.         end
  82.     end)
  83. end
  84.  
  85. function findPrimaryTarget(Target)
  86.     if Target then
  87.         for _, Enemy in pairs(Enemies:GetChildren()) do
  88.             if Enemy == Target then
  89.                 shootTarget(Target)
  90.                 lookAtTarget(Target)
  91.             end
  92.         end
  93.     end
  94. end
  95.  
  96. function findPossibleTarget()
  97.     NearbyEnemies = {}
  98.     for _, Enemy in pairs(Enemies:GetChildren()) do
  99.         if Enemy:FindFirstChild("Torso") then
  100.             if (Torso.Position - Enemy.Torso.Position).magnitude < _Range.Value then
  101.                 table.insert(NearbyEnemies, Enemy)
  102.                 findPrimaryTarget(NearbyEnemies[1])
  103.             end
  104.         end
  105.     end
  106. end
  107.  
  108. spawn(function()
  109.     while wait() do
  110.         findPossibleTarget()
  111.     end
  112. end)
Advertisement
Add Comment
Please, Sign In to add comment