Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Made by DoogleFox, don't care what people say.. It's the truth.
- bin = Instance.new("Tool")
- bin.Name = "Sniper"
- bin.Parent = game:service("Players").LocalPlayer.Backpack
- script.Parent = bin
- local CrouchingAccuracy = 0
- local StandingAccuracy = 2
- local Accuracy = StandingAccuracy
- local mindmg = 60
- local maxdmg = 90
- local thecrouchwalkspeed = 16
- local crouchingwalkspeed = 4
- local AntiTK = false
- local MaxAmmo = 8080
- local AmmoPerClip = 3
- local ShootSpeed = 1.1
- local ShotsPerAmmo = 1
- haz = Instance.new("Part", bin)
- haz.formFactor = "Custom"
- haz.Name = "Handle2"
- haz.Size = Vector3.new(0.5,0.5,0.5)
- haz.BrickColor = BrickColor.new("Black")
- haz.Locked = true
- haz.CanCollide = true
- haz.Anchored = false
- haz.TopSurface = 0
- haz.BottomSurface = 0
- mesh = Instance.new("SpecialMesh", haz)
- mesh.MeshId = "http://www.roblox.com/asset/?id=2761723"
- -- mesh.TextureId = "http://www.roblox.com/asset/?id=6465264"
- mesh.Scale = Vector3.new(0.55,0.55,0.45)
- han = Instance.new("Part", bin)
- han.formFactor = "Custom"
- han.Name = "Handle"
- han.Size = Vector3.new(0.5,1.2,2.5)
- han.BrickColor = BrickColor.new("Royal purple")
- han.Locked = true
- han.CanCollide = true
- han.Anchored = false
- han.TopSurface = 0
- han.BottomSurface = 0
- han.Transparency = 1
- local Joint1
- local Joint2
- local Joint3
- local Joint4
- local Torsoz = bin.Parent.Parent.Character.Torso
- local LA = bin.Parent.Parent.Character:findFirstChild("Left Arm")
- local RA = bin.Parent.Parent.Character:findFirstChild("Right Arm")
- local LL = bin.Parent.Parent.Character:findFirstChild("Left Leg")
- local RL = bin.Parent.Parent.Character:findFirstChild("Right Leg")
- local LeftJoint = Torsoz:findFirstChild("Left Shoulder")
- local RightJoint = Torsoz:findFirstChild("Right Shoulder")
- local LeftJoint2 = Torsoz:findFirstChild("Left Hip")
- local RightJoint2 = Torsoz:findFirstChild("Right Hip")
- local NeckJoint = Torsoz:findFirstChild("Neck")
- local GunWeld
- local PlayGui = bin.Parent.Parent.PlayerGui
- local CurrentAmmo = Instance.new("NumberValue")
- CurrentAmmo.Name = "CurrentAmmo"
- CurrentAmmo.Value = MaxAmmo
- local CurrentAmmoClip = Instance.new("NumberValue")
- CurrentAmmoClip.Name = "CurrentAmmoInClip"
- CurrentAmmoClip.Value = AmmoPerClip
- ----------------------------------------------- Gui ----------------------------------------------
- local gui = Instance.new("ScreenGui")
- gui.Name = "Ammo Gui"
- local t = Instance.new("TextLabel", gui)
- t.Name = "Bak"
- t.Text = ""
- t.BackgroundColor = BrickColor.new("Really black")
- t.TextColor = BrickColor.new("White")
- t.Position = UDim2.new(0.45,0,0.82,0)
- t.Size = UDim2.new(0.1,0,0.045,0)
- t.BorderColor = BrickColor.new("Really red")
- t.FontSize = 4
- local t3 = t:Clone()
- t2 = t:Clone()
- t3.Parent = t
- t3.Name = "Title"
- t3.Size = UDim2.new(1,0,-0.6,0)
- t3.Text = ""
- t3.Position = UDim2.new(0,0,0,0)
- t2.Parent = t
- t2.Name = "Front"
- t2.BorderColor = BrickColor.new("Dark stone grey")
- t2.Size = UDim2.new(0.9,0,0.9)
- t2.Position = UDim2.new(0.05,0,0.05,0)
- t2.Text = CurrentAmmoClip.Value .. " / " .. CurrentAmmo.Value
- t4 = t2:Clone()
- t4.Parent = t3
- t4.Text = "Ammo"
- coroutine.resume(coroutine.create(function()
- CurrentAmmoClip.Changed:connect(function()
- if CurrentAmmoClip.Value < 0 then
- CurrentAmmoClip.Value = 0
- end
- if CurrentAmmoClip.Value > AmmoPerClip then
- CurrentAmmoClip.Value = AmmoPerClip
- end
- if CurrentAmmo.Value > MaxAmmo then
- CurrentAmmo.Value = MaxAmmo
- end
- if CurrentAmmo.Value < 0 then
- CurrentAmmo.Value = 0
- end
- t2.Text = CurrentAmmoClip.Value .. " / " .. CurrentAmmo.Value
- end)
- end))
- coroutine.resume(coroutine.create(function()
- CurrentAmmo.Changed:connect(function()
- if CurrentAmmoClip.Value < 0 then
- CurrentAmmoClip.Value = 0
- end
- if CurrentAmmoClip.Value > AmmoPerClip then
- CurrentAmmoClip.Value = AmmoPerClip
- end
- if CurrentAmmo.Value > MaxAmmo then
- CurrentAmmo.Value = MaxAmmo
- end
- if CurrentAmmo.Value < 0 then
- CurrentAmmo.Value = 0
- end
- t2.Text = CurrentAmmoClip.Value .. " / " .. CurrentAmmo.Value
- end)
- end))
- ------------------------------------------------------------------------------------------------
- function PlaySound(ID, pit, vol)
- local f = Instance.new("Sound")
- f.Parent = game:service("Players").LocalPlayer.Character.Head
- f.Name = "Fire"
- f.SoundId = ID
- f.Looped = false
- f.Archivable = true
- f.PlayOnRemove = false
- f.Pitch = pit
- f.Volume = vol
- f:Play()
- game:service("Debris"):AddItem(f, 2)
- end
- local Down = Instance.new("NumberValue")
- Down.Name = "IsDown"
- local ReloadReady = true
- function Shoot(mouse)
- local pos1z = (haz.Position + Vector3.new(0,0.3,0)) + (haz.CFrame.lookVector * 2.55)
- local tempos = (CFrame.new(pos1z, mouse.Hit.p) * CFrame.Angles((math.random(-Accuracy, Accuracy)/100),math.random(-Accuracy, Accuracy)/100,math.random(-Accuracy, Accuracy)/100))
- local pos2z = mouse.Hit.p
- local ray = Ray.new(pos1z, tempos.lookVector*850)
- local hitz, enz = workspace:findPartOnRay(ray, Torsoz.Parent)
- local line = Instance.new("Part", bin)
- line.Anchored = true
- line.Locked = true
- line.CanCollide = false
- line.TopSurface = 0
- line.BottomSurface = 0
- line.Name = "BulletStreak"
- line.Size = Vector3.new(0.5,0.5,0.5)
- line.CanCollide = false
- line.BrickColor = BrickColor.new("Really black")
- line.Transparency = 0.55
- line.CFrame = CFrame.new((pos1z + enz)/2, pos1z)
- local muz = line:Clone()
- muz.Parent = bin
- muz.Anchored = false
- muz.Transparency = 0.75
- muz.CFrame = (haz.CFrame + Vector3.new(0,0.3,0)) + (haz.CFrame.lookVector * 2)
- local meshz = Instance.new("SpecialMesh", muz)
- meshz.MeshType = "Sphere"
- meshz.Scale = Vector3.new(0.7,0.7,1.45)
- muzw = Instance.new("Weld", muz)
- muzw.Part0 = haz
- muzw.Part1 = muz
- muzw.C0 = CFrame.new(0,0.3,-2.75)
- local mesh = Instance.new("BlockMesh", line)
- mesh.Scale = Vector3.new(0.12,0.12,(pos1z - enz).magnitude+0.3)
- game:service("Debris"):AddItem(line, (0.038*5))
- game:service("Debris"):AddItem(muz, 0.06)
- if hitz.Parent.className == "Model" then
- for _, hu in pairs(hitz.Parent:children()) do
- if hu.className == "Humanoid" then
- if AntiTK == true then
- if game:service("Players"):GetPlayerFromCharacter(hitz.Parent).Neutral == true or game:service("Players"):GetPlayerFromCharacter(hitz.Parent).TeamColor ~= game:service("Players").LocalPlayer.TeamColor then
- hu.Health = hu.Health - math.random(mindmg*10, maxdmg*10)/10
- if hitz.Name == "Head" then
- hu.Health = hu.Health - math.random(mindmg*10, maxdmg*10)/10/2
- end
- end
- elseif AntiTK == false then
- hu.Health = hu.Health - math.random(mindmg*10, maxdmg*10)/10
- if hitz.Name == "Head" then
- hu.Health = hu.Health - math.random(mindmg*10, maxdmg*10)/10/2
- end
- end
- end
- end
- elseif hitz.Parent.className == "Hat" and hitz.Parent.Parent.className == "Model" then
- for _, hu in pairs(hitz.Parent.Parent:children()) do
- if hu.className == "Humanoid" then
- if AntiTK == true then
- if game:service("Players"):GetPlayerFromCharacter(hitz.Parent.Parent).Neutral == true or game:service("Players"):GetPlayerFromCharacter(hitz.Parent.Parent).TeamColor ~= game:service("Players").LocalPlayer.TeamColor then
- hu.Health = hu.Health - math.random(mindmg*10, maxdmg*10)/10
- hu.Health = hu.Health - (math.random(mindmg*10, maxdmg*10)/10)/2
- end
- elseif AntiTK == false then
- hu.Health = hu.Health - math.random(mindmg*10, maxdmg*10)/10
- hu.Health = hu.Health - (math.random(mindmg*10, maxdmg*10)/10)/2
- end
- end
- end
- hitz:BreakJoints()
- end
- for _ = 1, 5 do
- line.Transparency = line.Transparency + 0.08
- mesh.Scale = mesh.Scale + Vector3.new(-0.03,-0.03,0)
- wait(0.038)
- end
- end
- function RecoilAnim()
- Joint1.C0 = CFrame.new(-0.2,0.525,-1.08) * CFrame.Angles(math.pi/1.85,0,0.5)
- Joint2.C0 = CFrame.new(1,0.525,-0.63) * CFrame.Angles(math.pi/1.85,0,-math.pi/12)
- Joint5.C0 = CFrame.new(0.2,1.35,0) * CFrame.Angles(0.12,0,-0.125)
- wait(0.08)
- Joint1.C0 = CFrame.new(-0.2,0.5,-1.2) * CFrame.Angles(math.pi/2,0,0.5)
- Joint2.C0 = CFrame.new(1,0.5,-0.75) * CFrame.Angles(math.pi/2,0,-math.pi/12)
- Joint5.C0 = CFrame.new(0.2,1.35,0) * CFrame.Angles(0,0,-0.125)
- end
- function onButton1Down(mouse)
- if ReloadReady == true then
- Down.Value = math.random(0, 80000)
- local tehval = Down.Value
- while Down.Value == tehval do
- ReloadReady = false
- if CurrentAmmoClip.Value > 0 then
- for _ = 1, ShotsPerAmmo do
- coroutine.resume(coroutine.create(Shoot), mouse)
- end
- coroutine.resume(coroutine.create(RecoilAnim))
- coroutine.resume(coroutine.create(function()
- local thepitch = math.random(6, 7)/10
- wait()
- coroutine.resume(coroutine.create(PlaySound), "http://roblox.com/asset/?id=10209803", thepitch, 0.75)
- end))
- CurrentAmmoClip.Value = CurrentAmmoClip.Value - 1
- end
- wait(ShootSpeed)
- end
- ReloadReady = true
- end
- end
- function onButton1Up()
- Down.Value = math.random(0, 80000)
- end
- function Reload()
- if CurrentAmmo.Value > 0 then
- local amount = CurrentAmmoClip.Value + CurrentAmmo.Value
- if amount < AmmoPerClip then
- CurrentAmmoClip.Value = amount
- CurrentAmmo.Value = 0
- elseif amount >= AmmoPerClip then
- CurrentAmmoClip.Value = AmmoPerClip
- CurrentAmmo.Value = amount - AmmoPerClip
- end
- end
- end
- local crouchingz = false
- local inscope = false
- function Scope(mouse)
- inscope = true
- game:service("Players").LocalPlayer.Character.Humanoid.WalkSpeed = 0
- workspace.CurrentCamera.FieldOfView = 42
- end
- function onKeyDown(key, mouse)
- if key ~= nil then
- key:lower()
- if key == "q" then
- bin.Name = "Deselect = Remove"
- bin.Unequipped:connect(function() wait() bin:remove() end)
- elseif key == "r" then
- if ReloadReady == true then
- coroutine.resume(coroutine.create(Reload))
- end
- elseif key == "c" then
- game:service("Players").LocalPlayer.Character.Humanoid.WalkSpeed = crouchingwalkspeed
- Accuracy = CrouchingAccuracy
- CrouchAnim("Crouch")
- crouchingz = true
- if inscope == true then
- game:service("Players").LocalPlayer.Character.Humanoid.WalkSpeed = 0
- end
- elseif key == "z" then
- if inscope == false then
- coroutine.resume(coroutine.create(Scope), mouse)
- else
- inscope = false
- workspace.CurrentCamera.FieldOfView = 70
- if crouchingz == true then
- game:service("Players").LocalPlayer.Character.Humanoid.WalkSpeed = crouchingwalkspeed
- else
- game:service("Players").LocalPlayer.Character.Humanoid.WalkSpeed = thecrouchwalkspeed
- end
- end
- end
- end
- end
- function onKeyUp(key)
- if key ~= nil then
- key:lower()
- if key == "c" then
- game:service("Players").LocalPlayer.Character.Humanoid.WalkSpeed = thecrouchwalkspeed
- Accuracy = StandingAccuracy
- CrouchAnim("Stand")
- crouchingz = false
- if inscope == true then
- game:service("Players").LocalPlayer.Character.Humanoid.WalkSpeed = 0
- end
- end
- end
- end
- equiped = false
- function FaceTarget(mouse)
- local bg = Instance.new("BodyGyro")
- bg.maxTorque = Vector3.new(math.huge,math.huge,math.huge)
- bg.D = 100
- bg.Parent = Torsoz
- local pos1 = Torsoz.Position
- local pos2 = Vector3.new(mouse.Hit.x, pos1.y,mouse.Hit.z)
- bg.cframe = CFrame.new(pos1, pos2)
- equiped = true
- while equiped == true do
- pos1 = Torsoz.Position
- pos2 = Vector3.new(mouse.Hit.x, pos1.y,mouse.Hit.z)
- bg.cframe = CFrame.new(pos1, pos2)
- wait()
- end
- game:service("Debris"):AddItem(bg, 0)
- end
- function Armz()
- LeftJoint.Part0 = nil
- RightJoint.Part0 = nil
- NeckJoint.Part0 = nil
- Joint1 = Instance.new("Motor", Torsoz)
- Joint2 = Instance.new("Motor", Joint1.Parent)
- Joint5 = Instance.new("Motor", Joint1.Parent)
- Joint1.Part0 = Joint1.Parent
- Joint2.Part0 = Joint1.Parent
- Joint5.Part0 = Joint1.Parent
- Joint1.Part1 = bin.Parent:findFirstChild("Left Arm")
- Joint2.Part1 = bin.Parent:findFirstChild("Right Arm")
- Joint5.Part1 = bin.Parent:findFirstChild("Head")
- Joint1.C0 = CFrame.new(-0.2,0.5,-1.2) * CFrame.Angles(math.pi/2,0,0.5)
- Joint2.C0 = CFrame.new(1,0.5,-0.75) * CFrame.Angles(math.pi/2,0,-math.pi/12)
- Joint5.C0 = CFrame.new(0.2,1.35,0) * CFrame.Angles(0,0,-0.125)
- end
- local meshi = Instance.new("SpecialMesh")
- meshi.MeshType = "Brick"
- meshi.Scale = Vector3.new(1.02,10,1.02)
- local meshi2 = meshi:Clone()
- function CrouchAnim(which)
- if which == "Stand" then
- Joint3:remove()
- Joint4:remove()
- meshi.Parent = nil
- meshi2.Parent = nil
- RL.formFactor = "Symmetric"
- LL.formFactor = "Symmetric"
- RL.Size = Vector3.new(1,2,1)
- LL.Size = Vector3.new(1,2,1)
- LeftJoint2.Part0 = Torsoz
- RightJoint2.Part0 = Torsoz
- elseif which == "Crouch" then
- LeftJoint2.Part0 = nil
- RightJoint2.Part0 = nil
- meshi.Parent = RL
- meshi2.Parent = LL
- RL.formFactor = "Custom"
- LL.formFactor = "Custom"
- RL.Size = Vector3.new(1,0.2,1)
- LL.Size = Vector3.new(1,0.2,1)
- Joint3 = Instance.new("Motor", Torsoz)
- Joint4 = Instance.new("Motor", Joint3.Parent)
- Joint3.Part0 = Joint3.Parent
- Joint4.Part0 = Joint3.Parent
- Joint3.Part1 = bin.Parent:findFirstChild("Left Leg")
- Joint4.Part1 = bin.Parent:findFirstChild("Right Leg")
- Joint3.C0 = CFrame.new(-0.5,-0.8,0.75) * CFrame.Angles(-math.pi/2,0,0)
- Joint4.C0 = CFrame.new(0.5,-0.3,-1)
- end
- end
- bin.Equipped:connect(function(mouse)
- LeftJoint = Torsoz:findFirstChild("Left Shoulder")
- RightJoint = Torsoz:findFirstChild("Right Shoulder")
- LeftJoint2 = Torsoz:findFirstChild("Left Hip")
- RightJoint2 = Torsoz:findFirstChild("Right Hip")
- NeckJoint = Torsoz:findFirstChild("Neck")
- han.Parent = bin
- haz.Parent = bin
- gui.Parent = PlayGui
- mouse.Icon = "rbxasset://textures\\GunCursor.png"
- mouse.Button1Down:connect(function() onButton1Down(mouse) end)
- mouse.Button1Up:connect(function() onButton1Up(mouse) end)
- mouse.KeyDown:connect(function(key) onKeyDown(key, mouse) end)
- mouse.KeyUp:connect(function(key) onKeyUp(key) end)
- wait(0.1)
- coroutine.resume(coroutine.create(Armz))
- coroutine.resume(coroutine.create(FaceTarget), mouse)
- if GunWeld ~= nil then
- GunWeld:remove()
- end
- GunWeld = Instance.new("Weld")
- GunWeld.Parent = bin
- GunWeld.Part0 = han
- GunWeld.Part1 = haz
- GunWeld.C0 = CFrame.new(0,0.25,-0.5) * CFrame.Angles(0,-0.2,0)
- han.CanCollide = false
- haz.CanCollide = true
- end)
- bin.Unequipped:connect(function()
- equiped = false
- gui.Parent = nil
- Joint1:remove()
- Joint2:remove()
- Joint5:remove()
- LeftJoint.Part0 = Torsoz
- RightJoint.Part0 = Torsoz
- NeckJoint.Part0 = Torsoz
- if LA ~= nil then
- LeftJoint.Part1 = LA
- end
- if RA ~= nil then
- RightJoint.Part1 = RA
- end
- for _, vv in pairs(Torsoz:children()) do
- if vv.className == "BodyGyro" then
- vv:remove()
- end
- end
- if GunWeld ~= nil then
- GunWeld:remove()
- end
- GunWeld = Instance.new("Weld")
- GunWeld.Parent = bin
- GunWeld.Part0 = han
- GunWeld.Part1 = haz
- han.CanCollide = true
- haz.CanCollide = false
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement