Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Players = game:GetService("Players")
- local Workspace = game:GetService("Workspace")
- local ReplicatedFirst = game:GetService("ReplicatedFirst")
- local ReplicatedStorage = game:GetService("ReplicatedStorage"):WaitForChild("ReplicatedStorage_CLOUD")
- local Script = script
- local Model = script.Parent
- local Torso = Model:WaitForChild("Torso")
- local Head = Model:WaitForChild("Head")
- local Humanoid = Model:WaitForChild("Humanoid")
- local Handle = Model:WaitForChild("Handle")
- local Output = Handle:WaitForChild("Output")
- local Input = Handle:WaitForChild("Input")
- local Rocket = Handle:WaitForChild("Rocket")
- local Configuration = Model:WaitForChild("Configuration")
- local _Damage = Configuration:WaitForChild("Damage")
- local _Range = Configuration:WaitForChild("Range")
- local _Can = Configuration:WaitForChild("Can")
- local _ReloadTime = Configuration:WaitForChild("ReloadTime")
- local Enemies = Workspace:WaitForChild("Enemy")
- local NearbyEnemies = {}
- function awardPlayers()
- for _, v in pairs(Players:GetChildren()) do
- if v:FindFirstChild("leaderstats") then
- if v["leaderstats"]:FindFirstChild("Money") then
- v["leaderstats"]["Money"].Value = v["leaderstats"]["Money"].Value + 1
- end
- end
- end
- end
- function lookAtTarget(Target)
- if Target then
- Torso.CFrame = CFrame.new(Torso.Position, Vector3.new(Target["Torso"].Position.X, Torso.Position.Y, Target["Torso"].Position.Z))
- end
- end
- function shootTarget(Target)
- spawn(function()
- if _Can.Value == true then
- _Can.Value = false
- spawn(function()
- Output["FireSound"]:Play()
- wait(0.25)
- Output["ExplosionSound"]:Play()
- end)
- spawn(function()
- Rocket.Transparency = 1
- wait(0.25)
- Rocket.Transparency = 0
- end)
- spawn(function()
- Input["1FlashFX[Smoke]"].Enabled = true
- Input["FlashFX[Flash]"].Enabled = true
- wait(0.15)
- Input["1FlashFX[Smoke]"].Enabled = false
- Input["FlashFX[Flash]"].Enabled = false
- end)
- spawn(function()
- Output["1FlashFX[Smoke]"].Enabled = true
- Output["FlashFX[Flash]"].Enabled = true
- Output["FlashFX[Light]"].Enabled = true
- wait(0.08)
- Output["1FlashFX[Smoke]"].Enabled = false
- Output["FlashFX[Flash]"].Enabled = false
- Output["FlashFX[Light]"].Enabled = false
- end)
- spawn(function()
- if Target:FindFirstChild("Humanoid") then
- Target.Humanoid:TakeDamage(_Damage.Value)
- end
- end)
- awardPlayers()
- wait(_ReloadTime.Value)
- _Can.Value = true
- end
- end)
- end
- function findPrimaryTarget(Target)
- if Target then
- for _, Enemy in pairs(Enemies:GetChildren()) do
- if Enemy == Target then
- shootTarget(Target)
- lookAtTarget(Target)
- end
- end
- end
- end
- function findPossibleTarget()
- NearbyEnemies = {}
- for _, Enemy in pairs(Enemies:GetChildren()) do
- if Enemy:FindFirstChild("Torso") then
- if (Torso.Position - Enemy.Torso.Position).magnitude < _Range.Value then
- table.insert(NearbyEnemies, Enemy)
- findPrimaryTarget(NearbyEnemies[1])
- end
- end
- end
- end
- spawn(function()
- while wait() do
- findPossibleTarget()
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment