Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- player = game.Players.LocalPlayer
- mouse = player:GetMouse()
- maxAmmo = 250
- ammo = maxAmmo
- rate = 0.002
- firing= false
- canFire= true
- reload = 2
- damage = 12
- script.Parent.Activated:Connect(function()
- if ammo >= 1 and canFire == true then
- firing = true
- repeat local bullet= Instance.new("Part", workspace)
- bullet.CanCollide = false
- bullet.Shape = "Ball"
- bullet.Material = "Neon"
- bullet.BrickColor = BrickColor.new("Bright red")
- bullet.Size = Vector3.new(0.4,0.4,0.4)
- local Axis = CFrame.new(script.Parent.Handle.Position, mouse.Hit.p)
- local spread = math.rad(2)
- local Theta = math.random() * math.pi * 2
- local Phi = math.random() * spread
- local x = math.cos(Theta) * math.sin(Phi)
- local y = math.sin(Theta) * math.sin(Phi)
- local z = math.cos(Phi)
- local Coordinate = Axis * CFrame.fromEulerAnglesXYZ(x,y,z)
- bullet.CFrame = Coordinate
- local vel = Instance.new("BodyVelocity")
- vel.Velocity = bullet.CFrame.LookVector*250
- game.Debris:AddItem(bullet, 15)
- bullet.Touched:Connect(function(hit)
- if hit.Parent ~= player.Character and hit.Parent:FindFirstChild("Humanoid") then
- hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - damage
- bullet:Destroy()
- end
- end)
- wait(rate)
- until ammo < 1 or firing == false
- end
- end)
- script.Parent.Deactivated:Connect(function()
- if firing == true then
- firing = false
- end
- end)
- mouse.KeyDown:Connect(function(k)
- if string.lower(k) == "r" and ammo < maxAmmo and firing == false then
- canFire = false
- wait(reload)
- ammo = maxAmmo
- canFire = true
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement