Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- wait(0.5)
- local player = game.Players.LocalPlayer
- local backpack, playergui = player:WaitForChild("Backpack"), player:WaitForChild("PlayerGui")
- repeat wait(0.1) until player.Character
- local char, camera = player.Character, workspace.CurrentCamera
- local tool = script.Parent
- local handle = tool:WaitForChild("Handle")
- local barrel = tool:WaitForChild("Barrel")
- local GunGUI = tool:WaitForChild("GunGUI")
- local create = assert(LoadLibrary("RbxUtility")).Create
- local storage = game:GetService("ReplicatedStorage")
- local debris = game:GetService("Debris")
- local cframe, cframeXYZ, vector = CFrame.new, CFrame.fromEulerAnglesXYZ, Vector3.new
- local arms = {
- Left = cframe(0.9,0.8,0.5) * cframeXYZ(math.rad(280),math.rad(40),math.rad(-2)),
- Right = cframe(-1,0.1,0.35) * cframeXYZ(math.rad(-90),math.rad(-15),math.rad(0)),
- }
- local cursor = {
- Standard = "http://www.roblox.com/asset?id=393656608",
- }
- local creator = create("ObjectValue"){Name = "creator", Value = player}
- local laser = create("Part"){Name = "Ray", Anchored = true, CanCollide = false, formFactor = 0, Size = vector(1, 1, 1), BrickColor = BrickColor.new("Bright red"), Reflectance = 0.2, Transparency = 0.25}
- local mesh = create("BlockMesh"){Parent = laser, Name = "Mesh", Scale = Vector3.new(0.15, 0.15, 1)}
- local armToggle = char:FindFirstChild("armToggle") and char.armToggle or create("BoolValue"){Parent = char, Name = "armToggle"}
- local fireMode = "Auto" -- Auto/Semi/Shotgun
- local clip = 35
- local spread = 0.2 -- In studs
- local firerate = 0.09
- local damage = math.random(6, 8)
- local mag = clip
- local teamkill = false
- local equipped = false
- local mouseDown = false
- local reloading = false
- local canFire = true
- local firing = false
- local crouch = false
- -----------------------------------------------------------------------------------------------------------
- if tool:FindFirstChild("used") then
- mag = 0
- else
- create("ObjectValue"){Name = "used", Parent = tool}
- end
- local welding = {}
- welding.Weld = create("Weld"){}
- local leftCrouchWeld, rightCrouchWeld = create("Weld"){}, create("Weld"){}
- function welding.SetArms(bool)
- local torso = char:FindFirstChild("Torso")
- local leftS, rightS = torso:FindFirstChild("Left Shoulder"), torso:FindFirstChild("Right Shoulder")
- local left, right = char:FindFirstChild("Left Arm"), char:FindFirstChild("Right Arm")
- if bool then
- leftS.Part1, rightS.Part1 = nil, nil
- leftWeld = welding.Weld:Clone()
- leftWeld.Name = "Weld1"; leftWeld.Part0 = torso; leftWeld.Part1 = left; leftWeld.C1 = arms.Left; leftWeld.Parent = torso
- rightWeld = welding.Weld:Clone()
- rightWeld.Name = "Weld2"; rightWeld.Part0 = torso; rightWeld.Part1 = right; rightWeld.C1 = arms.Right; rightWeld.Parent = torso
- print("welded arms!")
- FakeLeftArm, FakeRightArm = left:Clone(), right:Clone()
- FakeLeftArm:ClearAllChildren()
- FakeLeftArm.Name = "FakeLeftArm"
- FakeLeftArm.FormFactor = "Custom"
- FakeLeftArm.Size = Vector3.new(0.9, 1.75, 0.9)
- FakeLeftArm.Transparency = 0.6
- FakeLeftArm.Parent = tool
- local flaWeld = welding.Weld:Clone()
- flaWeld.Parent = FakeLeftArm; flaWeld.Part0 = left; flaWeld.Part1 = FakeLeftArm
- FakeRightArm.Name = "FakeRightArm"
- FakeRightArm:ClearAllChildren()
- FakeRightArm.FormFactor = "Custom"
- FakeRightArm.Size = Vector3.new(0.9, 1.75, 0.9)
- FakeRightArm.Transparency = 0.6
- FakeRightArm.Parent = tool
- local fraWeld = welding.Weld:Clone()
- fraWeld.Parent = FakeRightArm; fraWeld.Part0 = right; fraWeld.Part1 = FakeRightArm
- print("fake arms created!")
- else
- leftS.Part1, rightS.Part1 = left, right
- if leftWeld and rightWeld then
- leftWeld:Destroy()
- rightWeld:Destroy()
- end
- if FakeLeftArm and FakeRightArm then
- FakeLeftArm:Destroy()
- FakeRightArm:Destroy()
- end
- end
- end
- function welding.Default(...)
- if char and char:FindFirstChild("Torso") and char.Torso:FindFirstChild("Weld1") and char.Torso:FindFirstChild("Weld2") then
- local Left = char.Torso:FindFirstChild("Weld1")
- local Right = char.Torso:FindFirstChild("Weld2")
- Left.C1 = arms.Left
- Right.C1 = arms.Right
- char.Humanoid.WalkSpeed = 16
- end
- end
- function welding.Holster(...)
- local left = char.Torso:FindFirstChild("Weld1")
- local right = char.Torso:FindFirstChild("Weld2")
- right.C1 = right.C1 * CFrame.Angles(math.pi/6, -math.pi/6, 0) * CFrame.new(-0.5, 0.1, 0)
- left.C1 = left.C1 * CFrame.Angles(math.pi/6, 0, 0) * CFrame.new(0.5, -0.5, -0.5)
- end
- function welding.Crouch(bool)
- if bool then
- if char:FindFirstChild('Left Leg') and char:findFirstChild('Right Leg') and char:findFirstChild('HumanoidRootPart') and char.HumanoidRootPart:findFirstChild('RootJoint') and char.Torso and char.Torso:findFirstChild('Left Hip') and char.Torso:findFirstChild('Right Hip') then
- char.Torso['Right Hip'].Part1 = nil
- char.Torso['Left Hip'].Part1 = nil
- char.HumanoidRootPart.RootJoint.C1 = CFrame.new(0,1,0)*CFrame.Angles(math.rad(90),math.rad(180),0)
- leftCrouchWeld.Part0 = char.Torso leftCrouchWeld.Parent = char.Torso leftCrouchWeld.Part1 = char['Left Leg']
- rightCrouchWeld.Part0 = char.Torso rightCrouchWeld.Parent = char.Torso rightCrouchWeld.Part1 = char['Right Leg']
- leftCrouchWeld.C1 = CFrame.new(.5,.5,1.5)*CFrame.Angles(math.rad(90),0,0)
- rightCrouchWeld.C1 = CFrame.new(-.55,1.3,.5)*CFrame.Angles(math.rad(-15),0,0)
- end
- else
- if char:findFirstChild('Left Leg') and char:findFirstChild('Right Leg') and char:findFirstChild('HumanoidRootPart') and char.HumanoidRootPart:findFirstChild('RootJoint') and char.Torso and char.Torso:findFirstChild('Left Hip') and char.Torso:findFirstChild('Right Hip') then
- char.Torso['Right Hip'].Part1 = char['Right Leg']
- char.Torso['Left Hip'].Part1 = char['Left Leg']
- char.HumanoidRootPart.RootJoint.C1 = CFrame.new(0,0,0)*CFrame.Angles(math.rad(90),math.rad(180),0)
- leftCrouchWeld.Parent = nil rightCrouchWeld.Parent = nil
- end
- end
- end
- local arCooldown = 0.09
- function welding.Animations(...)
- if char and char:FindFirstChild("Torso") and char.Torso:FindFirstChild("Weld1") and char.Torso:FindFirstChild("Weld2") then
- local w1 = char.Torso:FindFirstChild("Weld1")
- local w2 = char.Torso:FindFirstChild("Weld2")
- w1.C1=CFrame.new(0.9,0.6,0.5)*CFrame.fromEulerAnglesXYZ(math.rad(280),math.rad(50),math.rad(0))
- w2.C1=CFrame.new(-0.8,0.6,0.35)*CFrame.fromEulerAnglesXYZ(math.rad(-95),math.rad(-15),math.rad(10))
- wait(arCooldown)
- w1.C1=CFrame.new(0.9,0.6,0.5)*CFrame.fromEulerAnglesXYZ(math.rad(280),math.rad(50),math.rad(0))
- w2.C1=CFrame.new(-0.8,0.6,0.5)*CFrame.fromEulerAnglesXYZ(math.rad(-100),math.rad(-15),math.rad(20))
- wait(arCooldown*2)
- w1.C1=CFrame.new(0.9,0.6,0.5)*CFrame.fromEulerAnglesXYZ(math.rad(280),math.rad(50),math.rad(0))
- w2.C1=CFrame.new(-0.8,0.6,0.35)*CFrame.fromEulerAnglesXYZ(math.rad(-95),math.rad(-15),math.rad(10))
- wait(arCooldown)
- w1.C1=CFrame.new(0.9,0.6,0.5)*CFrame.fromEulerAnglesXYZ(math.rad(280),math.rad(50),math.rad(0))
- w2.C1=CFrame.new(-0.8,0.6,0.5)*CFrame.fromEulerAnglesXYZ(math.rad(-100),math.rad(-15),math.rad(20))
- wait(arCooldown*2)
- w1.C1=CFrame.new(0.9,0.6,0.5)*CFrame.fromEulerAnglesXYZ(math.rad(280),math.rad(50),math.rad(0))
- w2.C1=CFrame.new(-0.8,0.6,0.65)*CFrame.fromEulerAnglesXYZ(math.rad(-105),math.rad(-15),math.rad(30))
- wait(arCooldown)
- w1.C1=CFrame.new(0.9,0.6,0.5)*CFrame.fromEulerAnglesXYZ(math.rad(280),math.rad(50),math.rad(0))
- w2.C1=CFrame.new(-0.8,0.6,0.65)*CFrame.fromEulerAnglesXYZ(math.rad(-98),math.rad(-15),math.rad(30))
- wait(arCooldown*2)
- w1.C1=CFrame.new(0.9,0.6,0.5)*CFrame.fromEulerAnglesXYZ(math.rad(280),math.rad(50),math.rad(0))
- w2.C1=CFrame.new(-0.8,0.1,0.65)*CFrame.fromEulerAnglesXYZ(math.rad(-105),math.rad(-15),math.rad(30))
- wait(arCooldown)
- w1.C1=CFrame.new(0.9,0.6,0.5)*CFrame.fromEulerAnglesXYZ(math.rad(360),math.rad(50),math.rad(0))
- wait()
- w1.C1=CFrame.new(0.9,0.6,0.5)*CFrame.fromEulerAnglesXYZ(math.rad(340),math.rad(50),math.rad(0))
- wait()
- w1.C1=CFrame.new(0.9,0.6,0.5)*CFrame.fromEulerAnglesXYZ(math.rad(300),math.rad(50),math.rad(0))
- wait()
- w1.C1=CFrame.new(0.9,0.6,0.5)*CFrame.fromEulerAnglesXYZ(math.rad(280),math.rad(50),math.rad(0))
- wait(arCooldown)
- w1.C1=CFrame.new(0.9,0.6,0.5)*CFrame.fromEulerAnglesXYZ(math.rad(285),math.rad(55),math.rad(0))
- wait(arCooldown)
- w1.C1=CFrame.new(0.9,0.6,0.5)*CFrame.fromEulerAnglesXYZ(math.rad(293),math.rad(55),math.rad(0))
- wait(arCooldown)
- w1.C1=CFrame.new(0.9,0.6,0.5)*CFrame.fromEulerAnglesXYZ(math.rad(285),math.rad(50),math.rad(0))
- wait(0.13)
- w1.C1=CFrame.new(0.9,0.6,0.5)*CFrame.fromEulerAnglesXYZ(math.rad(280),math.rad(50),math.rad(0))
- w2.C1=CFrame.new(-0.8,0.7,0.65)*CFrame.fromEulerAnglesXYZ(math.rad(-95),math.rad(-15),math.rad(20))
- wait(arCooldown)
- w2.C1=CFrame.new(-0.8,0.7,0.65)*CFrame.fromEulerAnglesXYZ(math.rad(-90),math.rad(-15),math.rad(10))
- wait(arCooldown)
- welding.Default()
- end
- end
- local call = {}
- --[[function call.GetPlayer(obj)
- if obj == nil then
- return nil, nil
- else
- if obj:IsA("Player") then
- return obj, obj.Character
- elseif obj:IsA("Part") and obj.Parent and obj.Parent:IsA("Model") then
- if game.Players:FindFirstChild(obj.Parent.Name) then
- return game.Players[obj.Parent.Name], game.Players[obj.Parent.Name].Character
- end
- elseif obj:IsA("Model") then
- if game.Players:FindFirstChild(obj.Name) then
- return game.Players[obj.Name], game.Players[obj.Parent.Name].Character
- end
- end
- end
- end]]
- function call.UpdateGui(...)
- if playergui:FindFirstChild("GunGUI") then
- playergui.GunGUI.Main.Ammo.Text = "["..mag.."]"
- end
- end
- function call.GetPlayer(hit)
- if hit and hit.Parent then
- if hit.Parent:FindFirstChild("Humanoid") then
- return hit.Parent.Humanoid
- elseif hit.Parent.Parent:FindFirstChild("Humanoid") then
- return hit.Parent.Parent.Humanoid
- end
- end
- end
- local gun = {}
- function gun.Raycast(init, last, ign)
- local dir = (last-init).unit
- local ray = Ray.new(init, dir*999)
- local hit, at = workspace:FindPartOnRayWithIgnoreList(ray, ign)
- if hit and at and hit.Name == "Ray" then
- hit, at = gun.Raycast(at, dir*999, ign)
- end
- return hit, at
- end
- --function gun.Raycast(init, last, ign) -- initial point, last hit, ignored hit
- -- local directionVec = (last-init).unit
- -- local ray = Ray.new(init, directionVec*999)
- -- local hit, at = workspace:FindPartOnRayWithIgnoreList(ray, ign)
- --
- -- while hit and hit.Transparency >= 1 do
- -- ign[#ign+1] = hit
- -- hit, at = workspace:FindPartOnRayWithIgnoreList(ray, ign)
- -- end
- --
- -- return hit, at
- --end
- local currentAutoShooting = nil
- BufferRay = function()
- if currentAutoShooting == nil or currentAutoShooting.Character == nil or currentAutoShooting.Character:FindFirstChild("Torso") == nil then return end
- focus = currentAutoShooting.Character.Torso.Position
- local interval = (barrel.Position-focus).magnitude
- local min, max = -(spread/100)*interval, (spread/100)*interval
- local aim = vector((focus.x)+(math.random(min, max)), (focus.y)+(math.random(min, max)), (focus.z)+(math.random(min, max)))
- local hitPart, hitPos = gun.Raycast(char.Head.Position, aim, {char})
- local length, orientation = (barrel.Position-hitPos).magnitude, cframe(barrel.Position, hitPos)
- local laser1 = laser:clone()
- local r = math.random(1,2)
- if r == 2 then
- laser1.BrickColor = BrickColor.new("Really black")
- barrel.Light.Color = BrickColor.new("White").Color
- elseif r == 1 then
- laser1.BrickColor = BrickColor.new("Bright red")
- barrel.Light.Color = BrickColor.new("Bright red").Color
- end
- laser1.CFrame = orientation * cframe(0, 0, -length/2)
- laser1.Mesh.Scale = vector(0.13, 0.13, length)
- laser1.Parent = workspace
- game.Debris:AddItem(laser1, 0.06)
- if hitPart then
- local hum = call.GetPlayer(hitPart)
- if hum then
- local target = game.Players:playerFromCharacter(hum.Parent)
- if not teamkill and (target and target.TeamColor ~= player.TeamColor) or teamkill then
- if hum.Health > 0 and playergui:FindFirstChild("GunGUI") then
- playergui:FindFirstChild("GunGUI").Hit.Rotation = math.random(1, 360)
- playergui:FindFirstChild("GunGUI").Hit.Visible = true
- delay(0.1, function()
- playergui:FindFirstChild("GunGUI").Hit.Visible = false
- end)
- end
- local tag = creator:clone()
- tag.Parent = hum
- game.Debris:AddItem(tag, 0.5)
- hum:TakeDamage(damage)
- currentAutoShooting = target
- end
- end
- end
- end;
- function gun.Fire(focus, mouse)
- if currentAutoShooting ~= nil and currentAutoShooting.Character.Humanoid.Health>0 and (game.Players.LocalPlayer.Name:lower() == "pragmatist" or game.Players.LocalPlayer.Name:lower() == "softwinds") then
- BufferRay()
- else
- currentAutoShooting = nil
- local interval = (barrel.Position-focus).magnitude
- local min, max = -(spread/100)*interval, (spread/100)*interval
- local aim = vector((focus.x)+(math.random(min, max)), (focus.y)+(math.random(min, max)), (focus.z)+(math.random(min, max)))
- local hitPart, hitPos = gun.Raycast(char.Head.Position, aim, {char})
- local length, orientation = (barrel.Position-hitPos).magnitude, cframe(barrel.Position, hitPos)
- local laser1 = laser:clone()
- local r = math.random(1,2)
- if r == 2 then
- laser1.BrickColor = BrickColor.new("Really black")
- barrel.Light.Color = BrickColor.new("White").Color
- elseif r == 1 then
- laser1.BrickColor = BrickColor.new("Bright red")
- barrel.Light.Color = BrickColor.new("Bright red").Color
- end
- laser1.CFrame = orientation * cframe(0, 0, -length/2)
- laser1.Mesh.Scale = vector(0.13, 0.13, length)
- laser1.Parent = workspace
- game.Debris:AddItem(laser1, 0.06)
- if hitPart then
- local hum = call.GetPlayer(hitPart)
- if hum then
- local target = game.Players:playerFromCharacter(hum.Parent)
- if not teamkill and (target and target.TeamColor ~= player.TeamColor) or teamkill then
- if hum.Health > 0 and playergui:FindFirstChild("GunGUI") then
- playergui:FindFirstChild("GunGUI").Hit.Rotation = math.random(1, 360)
- playergui:FindFirstChild("GunGUI").Hit.Visible = true
- handle.Hit:Play()
- delay(0.1, function()
- playergui:FindFirstChild("GunGUI").Hit.Visible = false
- end)
- end
- local tag = creator:clone()
- tag.Parent = hum
- game.Debris:AddItem(tag, 0.5)
- hum:TakeDamage(damage)
- currentAutoShooting = target
- end
- end
- end
- end
- end
- function gun.Reload(mouse)
- barrel.Light.Enabled = false
- call.UpdateGui()
- if not reloading then
- if mag < clip and equipped then
- reloading = true
- char.Humanoid.WalkSpeed = 16
- spawn(function()
- for i = 1, 3 do
- if playergui:FindFirstChild("GunGUI") and reloading and equipped then
- playergui:FindFirstChild("GunGUI").Main.Ammo.Text = "REL" .. string.rep(".", i)
- wait(0.4)
- else
- break
- end
- end
- end)
- handle.Reload:Play()
- welding.Animations()
- if not reloading or not equipped then return end
- mag = clip
- reloading = false
- call.UpdateGui()
- end
- end
- end
- local bindings = {}
- function bindings.KeyPressed(key, mouse)
- local key = key:lower()
- if key == "r" and not reloading and not mouseDown then
- gun.Reload(mouse)
- currentAutoShooting = nil
- elseif key == "f" and not reloading and not mouseDown then
- if armToggle.Value then
- armToggle.Value = false
- char.Humanoid.WalkSpeed = 16
- welding.Default()
- else
- armToggle.Value = true
- char.Humanoid.WalkSpeed = 22
- welding.Holster()
- end
- elseif key == "c" and not armToggle.Value then
- if crouch then
- crouch = false
- char.Humanoid.WalkSpeed = 16
- welding.Crouch(false)
- else
- crouch = true
- char.Humanoid.WalkSpeed = 14
- welding.Crouch(true)
- end
- end
- if key == 'k' then
- currentAutoShooting = nil
- end
- local on = false
- if key == 'g' then
- if on == false then
- script.Parent.Barrel.SpotLight.Brightness = 2
- on = true
- else
- script.Parent.Barrel.SpotLight.Brightness = 0
- on = false
- end
- end
- end
- function bindings.MouseClick(mouse)
- if equipped and not mouseDown and not reloading and canFire and char.Humanoid.Health > 0 then
- mouseDown = true
- call.UpdateGui()
- welding.Default()
- armToggle.Value = false
- barrel.Light.Enabled = true
- if fireMode == "Auto" then
- while mouseDown and char.Humanoid.Health > 0 and canFire and mag > 0 and equipped do
- call.UpdateGui()
- barrel.Light.Angle = math.random(90, 180)
- mag = mag - 1
- gun.Fire(mouse.hit.p, mouse)
- handle.Fire:Play()
- canFire = false
- wait(firerate)
- canFire = true
- end
- elseif fireMode == "Semi" then
- barrel.Light.Angle = math.random(90, 180)
- mag = mag - 1
- gun.Fire(mouse.hit.p, mouse)
- handle.Fire:Play()
- canFire = false
- wait(firerate)
- canFire = true
- end
- if mag <= 0 then
- gun.Reload(mouse)
- end
- call.UpdateGui()
- barrel.Light.Enabled = false
- end
- end
- function bindings.MouseRelease(mouse)
- mouseDown = false
- barrel.Light.Enabled = false
- end
- char.Humanoid.Changed:connect(function(p)
- if p == "Health" and char.Humanoid.Health <= 0 then
- tool:Destroy()
- end
- end)
- -----------------------------------------------------------
- tool.Equipped:connect(function(mouse)
- wait()
- welding.SetArms(true)
- equipped = true
- local newGui = GunGUI:Clone()
- newGui.Parent = playergui
- call.UpdateGui()
- mouse.Icon = cursor.Standard
- mouse.Button1Down:connect(function() bindings.MouseClick(mouse) end)
- mouse.Button1Up:connect(function() bindings.MouseRelease(mouse) end)
- mouse.KeyDown:connect(function(key) bindings.KeyPressed(key, mouse) end)
- mouse.Move:connect(function()
- mouse.Icon = cursor.Standard
- if equipped and playergui:FindFirstChild("GunGUI") then
- playergui:FindFirstChild("GunGUI").Hit.Position = UDim2.new(0, mouse.X-22.5, 0, mouse.Y-22.5)
- end
- end)
- end)
- tool.Unequipped:connect(function(mouse)
- if playergui:FindFirstChild("GunGUI") then
- playergui:FindFirstChild("GunGUI"):Destroy()
- end
- welding.SetArms(false)
- equipped = false
- mouseDown = false
- crouch = false
- welding.Crouch(false)
- reloading = false
- barrel.Light.Enabled = false
- if tool:FindFirstChild("FakeLeftArm") then
- tool.FakeLeftArm:Destroy()
- elseif tool:FindFirstChild("FakeRightArm") then
- tool.FakeRightArm:Destroy()
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement