Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tool = script.Parent
- local player = game:GetService("Players").LocalPlayer
- local character = workspace:WaitForChild(player.Name)
- local humanoid = character:WaitForChild("Humanoid")
- local shootingOn = false
- local mouse = player:GetMouse()
- local Ammo = script.Parent.AmmoScript.Ammo
- local FireTime = 0.1 -- counts in secs
- local canFire = true
- local equipped = false
- local shootingOn = false
- function Shoot()
- local ray = Ray.new(tool.Handle.CFrame.p, (mouse.Hit.p - tool.Handle.CFrame.p).unit * 300)
- local part, position = workspace:FindPartOnRay(ray, character, false, true)
- local beam = Instance.new("Part", workspace)
- beam.BrickColor = BrickColor.new("Bright yellow")
- beam.FormFactor = "Custom"
- beam.Material = "Neon"
- beam.Transparency = 0.25
- beam.Anchored = true
- beam.Locked = true
- beam.CanCollide = false
- local distance = (tool.Handle.CFrame.p - position).magnitude
- beam.Size = Vector3.new(0.3, 0.3, distance)
- beam.CFrame = CFrame.new(tool.Handle.CFrame.p, position) * CFrame.new(0, 0, -distance / 2)
- game:GetService("Debris"):AddItem(beam, 0.1)
- if part then
- local zombiePlayer = part.Parent:FindFirstChild("Zombie")
- if not zombiePlayer then
- zombiePlayer = part.Parent.Parent:FindFirstChild("Zombie")
- end
- if zombiePlayer then
- zombiePlayer:TakeDamage(15)
- end
- end
- end
- tool.Equipped:connect(function()
- equipped = true
- mouse.Button1Down:connect(function()
- shootingOn = true
- if equipped and canFire and Ammo.Value == 0 and humanoid.Health ~= 0 then
- canFire = false
- while shootingOn do
- Ammo.Value = Ammo.Value - 1
- script.Parent.Handle.Fire:Play()
- Shoot()
- wait(FireTime)
- canFire = true
- if not shootingOn or Ammo.Value == 0 or not equipped then
- break
- end
- end
- end
- end)
- mouse.Button1Up:connect(function()
- shootingOn = false
- end)
- end)
- tool.Unequipped:connect(function()
- equipped = false
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement