Guest User

sh

a guest
Jul 28th, 2017
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 11.57 KB | None | 0 0
  1.  
  2. Tool = script.Parent
  3. Handle = Tool:WaitForChild("Handle")
  4. player = game.Players.LocalPlayer
  5.  
  6. --Cursor Icons
  7. Normal_icon = "http://www.roblox.com/asset/?id=54019936"
  8. Friend_icon = "http://www.roblox.com/asset/?id=54019944"
  9. Enemy_icon = "http://www.roblox.com/asset/?id=54019939"
  10. Reload_icon = "http://www.roblox.com/asset/?id=54020165"
  11.  
  12. --Shot settings
  13. Shot_Color = BrickColor.new("Deep orange")
  14. mesh_id = ""
  15. texture_id = ""
  16. mesh_scale = Vector3.new(0,0,0)
  17. bullet_spin = Vector3.new(0,0,0)
  18.  
  19. --Gun function settings
  20. Clip_Size = 5
  21. Fire_Speed = 3
  22. Reload_Speed = 2
  23. Automatic = false
  24. Limited_Weapon = true
  25. Legendary_Weapon = false
  26. Weapon_Image = script.Parent.TextureId
  27. Shots_Per_Bullet = 1
  28. Inaccuracy = 20
  29. Distance = 365
  30. Bullet_Speed = 25
  31. Bullet_Gravity = 0
  32. Distance_With_No_Gravity = 0
  33. Damage = 56
  34. Head_Damage = 78
  35. Shoot_From = Vector3.new(0,0,-2) --head
  36. Shots = game.Workspace:findFirstChild("SHOTS")
  37. fire_sound = Handle.fire
  38. reload_sound = Handle.reload
  39.  
  40. --Cam settings
  41. cam = game.Workspace.CurrentCamera
  42. function GetCamAim()
  43.     return (cam.CoordinateFrame * CFrame.new(0,0,-100)).p
  44. end
  45.  
  46. function CheckIfZoomed()
  47.     local pos = cam.CoordinateFrame
  48.     local head = player.Character:findFirstChild("Head")
  49.     local dist = (pos.p - head.Position).magnitude
  50.     if dist < 3.6 then
  51.         return true
  52.     else
  53.         return false
  54.     end
  55. end
  56.  
  57.  
  58. shell = Instance.new("Part")
  59. shell.CanCollide = false
  60. shell.Name = "beam"
  61. shell.Anchored = true
  62. shell.formFactor = "Custom"
  63. shell.Size = Vector3.new(0.3,3,0.3)
  64. shell.Reflectance = 0.3
  65. shell.BrickColor = Shot_Color
  66. if mesh_id == "" then
  67.     m = Instance.new("BlockMesh",shell)
  68.     m.Scale = Vector3.new(0.3,0.8,0.3)
  69. else
  70.     m = Instance.new("SpecialMesh",shell)
  71.     m.MeshType = "FileMesh"
  72.     m.Scale = Vector3.new(1,1,1)
  73.     m.MeshId = mesh_id
  74.     m.TextureId = texture_id
  75. end
  76.  
  77. --Shell Settings
  78.  
  79. char = player.Character
  80. is_reloading = false
  81. last_shot = 0
  82. fireon = false
  83. is_reloading = false
  84. the_clip = Clip_Size
  85.  
  86. --GUI
  87. the_gui = player.PlayerGui:WaitForChild("HUD").gun
  88. ammtxt = the_gui.mag
  89. guntxt = the_gui.name
  90. gunimg = the_gui.gun
  91.  
  92. ------------------------------------
  93. cam = game.Workspace.CurrentCamera
  94. function GetCamAim()
  95.     return (cam.CoordinateFrame * CFrame.new(0,0,-100)).p
  96. end
  97.  
  98. function CheckIfZoomed()
  99.     local pos = cam.CoordinateFrame
  100.     local head = player.Character:findFirstChild("Head")
  101.     local dist = (pos.p - head.Position).magnitude
  102.     if dist < 3.6 then
  103.         return true
  104.     else
  105.         return false
  106.     end
  107. end
  108.  
  109.  
  110. shell = Instance.new("Part")
  111. shell.CanCollide = false
  112. shell.Name = "beam"
  113. shell.Anchored = true
  114. shell.formFactor = "Custom"
  115. shell.Size = Vector3.new(0.3,3,0.3)
  116. shell.Reflectance = 0.3
  117. shell.BrickColor = Shot_Color
  118. if mesh_id == "" then
  119.     m = Instance.new("BlockMesh",shell)
  120.     m.Scale = Vector3.new(0.3,0.8,0.3)
  121. else
  122.     m = Instance.new("SpecialMesh",shell)
  123.     m.MeshType = "FileMesh"
  124.     m.Scale = Vector3.new(1,1,1)
  125.     m.MeshId = mesh_id
  126.     m.TextureId = texture_id
  127. end
  128.  
  129.  
  130. char = player.Character
  131. is_reloading = false
  132. last_shot = 0
  133. fireon = false
  134. is_reloading = false
  135. the_clip = Clip_Size
  136.  
  137. function GetHumanoid(prt)
  138.     local h1 = prt.Parent:findFirstChild("Zombie")
  139.     local h2 = prt.Parent.Parent:findFirstChild("Zombie")
  140.     if h1 ~= nil then
  141.         return h1
  142.     else
  143.         return h2
  144.     end
  145. end
  146.  
  147. function check_aggressive(cl1,cl2)
  148.     if cl1 == BrickColor.new() or cl2 == BrickColor.new() then
  149.         return true
  150.     end
  151.     local tms = game.Teams
  152.     local alt = tms:findFirstChild("T4V Allies").TeamColor
  153.     local t4vt = tms:findFirstChild("T4V Members").TeamColor
  154.     local ent = tms:findFirstChild("Raiders").TeamColor
  155.     if cl1 == alt or cl1 == t4vt then
  156.         if cl2 == ent then return true end
  157.     else
  158.         if cl1 ~= cl2 then return true end
  159.     end
  160.     return false
  161. end
  162.  
  163. function GetPlayerFromHum(hum)
  164.     pl = game.Players:GetChildren()
  165.     for i = 1,#pl do
  166.         if pl[i].Character:findFirstChild("Humanoid") == hum then
  167.             return pl[i]
  168.         end
  169.     end
  170.     return nil
  171. end
  172.  
  173. function InspectTeam(hum)
  174.     if GetPlayerFromHum(hum) ~= nil then
  175.         return GetPlayerFromHum(hum).TeamColor
  176.     elseif hum.Parent:findFirstChild("AITEAM") ~= nil then
  177.         return hum.Parent:findFirstChild("AITEAM").Value
  178.     else
  179.         return BrickColor.new()
  180.     end
  181. end
  182.  
  183. function GetPosFromHum(hum)
  184.     if hum.Parent:findFirstChild("Torso") ~= nil then
  185.         return hum.Parent:findFirstChild("Torso").Position
  186.     else
  187.         return Vector3.new()
  188.     end
  189. end
  190.  
  191. function MyPos()
  192.     return char.Torso.Position
  193. end
  194.  
  195. function GiveDamage(Hitted_Part,Normal_Damage,HeadShot_Damage)
  196.     local htp = Hitted_Part
  197.     local dmg = Normal_Damage
  198.  
  199.     local dhm = GetHumanoid(htp)
  200.     if dhm == nil then return end
  201.  
  202.     if htp.Parent.className == "Hat" or htp.Name == "Head" then
  203.         dmg = HeadShot_Damage
  204.     end
  205.  
  206.     if dhm then
  207.         local h_team = InspectTeam(dhm)
  208.         if check_aggressive(player.TeamColor,h_team) then
  209.            
  210.             local tag = Instance.new("ObjectValue")
  211.             tag.Name = "creator"
  212.             tag.Value = player
  213.  
  214.         local   getps = GetPosFromHum(dhm)
  215.             if getps ~= Vector3.new() then
  216.             local   psval = Instance.new("IntValue",tag)
  217.                 psval.Name = "Distance"
  218.                 psval.Value = math.floor((getps-MyPos()).magnitude)
  219.             end
  220.  
  221.             tag.Parent = dhm
  222.             wait(0.1)
  223.             dhm:TakeDamage(dmg)
  224.             wait(2)
  225.             tag.Parent = nil
  226.         end
  227.     end
  228. end
  229.  
  230.  
  231. function Run(mouse)
  232.     if is_reloading then
  233.         mouse.Icon = Reload_icon
  234.         return
  235.     end
  236.     mouse.Icon = Normal_icon
  237.     local hit = mouse.Target
  238.     if (hit == nil) then print("") end
  239.     h = GetHumanoid(hit)
  240.     if h ~= nil then
  241.         local torso = hit.Parent.UpperTorso
  242.         if torso ~= nil then
  243.             if h.Health > 0 then
  244.                 if check_aggressive(player.TeamColor,InspectTeam(h)) then
  245.                     mouse.Icon = Enemy_icon
  246.                 else
  247.                     mouse.Icon = Friend_icon
  248.                 end
  249.             end
  250.         end
  251.     end
  252. end
  253.  
  254. function ShakeCam()
  255.     cam = game.Workspace.CurrentCamera
  256.     local function RandVector()
  257.         return Vector3.new(math.random(-100,100)/40000,math.random(-100,-20)/20000,math.random(-100,100)/40000)
  258.     end
  259. local   function Mult(vct,ml)
  260.         return Vector3.new(vct.x*ml,vct.y*ml,vct.z*ml)
  261.     end
  262.     local tvc = RandVector()
  263.     local tam = math.random(3,3)
  264.     for i = 1,tam do
  265.         cam.CoordinateFrame = cam.CoordinateFrame * CFrame.new(Mult(tvc,math.sin(math.rad((90/tam)*i))))
  266.         wait()
  267.     end
  268.     for i = tam,1,-1 do
  269.         cam.CoordinateFrame = cam.CoordinateFrame * CFrame.new(Mult(-tvc,math.sin(math.rad((90/tam)*i))))
  270.         wait()
  271.     end
  272. end
  273.  
  274. ------------------------------------------------------------------------
  275. function on(mouse)
  276.     fireon = false
  277.     ammtxt.Text = the_clip .. " / " .. Clip_Size
  278. guntxt.Text = script.Parent.Name
  279. if Limited_Weapon == true then
  280.     guntxt.TextColor3 = Color3.new(255, 255, 0)
  281.     guntxt.TextStrokeColor3 = Color3.new(255, 255, 0)
  282. end
  283. gunimg.Image = Weapon_Image
  284.  
  285.     mouse.Button1Down:connect(function()
  286.         fireon = true
  287.         if not Automatic then
  288.             shot()
  289.         end
  290.     end)
  291.     mouse.Button1Up:connect(function()
  292.         fireon = false
  293.     end)
  294.  
  295.     function onKeyDown(key)
  296.         if (key~=nil) then
  297.             key = key:lower()
  298.             if key == "r" and the_clip < Clip_Size then
  299.                 if is_reloading then return end
  300.                 ammtxt.Text = "..."
  301.                 is_reloading = true
  302.                 if reload_sound ~= nil then
  303.                     reload_sound:play()
  304.                 end
  305.                 wait(Reload_Speed)
  306.                 the_clip = Clip_Size
  307.                 is_reloading = false
  308.                 ammtxt.Text = the_clip .. " / " .. Clip_Size
  309.             end
  310.         end
  311.     end
  312.     mouse.KeyDown:connect(onKeyDown)
  313.  
  314.     function shot()
  315.         if char.Humanoid.Health <= 0 then return end
  316.         if is_reloading then return end
  317.         if tick() - last_shot < Fire_Speed  and the_clip > 0 then return end
  318.         if the_clip <= 0 then
  319.             ammtxt.Text = "..."
  320.             is_reloading = true
  321.             if reload_sound ~= nil then
  322.                 reload_sound:play()
  323.             end
  324.             wait(Reload_Speed)
  325.             the_clip = Clip_Size
  326.             is_reloading = false
  327.             ammtxt.Text = the_clip .. " / " .. Clip_Size
  328.         else
  329.             script.Parent.Recoil.Value = 6
  330.             last_shot = tick()
  331.             the_clip = the_clip - 1
  332.             ammtxt.Text = the_clip .. " / " .. Clip_Size
  333.             if fire_sound ~= nil then
  334.                 fire_sound:play()
  335.             end
  336.             if CheckIfZoomed() then
  337.                 PreFire(GetCamAim())
  338.             else
  339.                 PreFire(mouse.Hit.p)
  340.             end
  341.         end
  342.     end
  343.  
  344.     while true do
  345.         wait()
  346.         Run(mouse)
  347.     end
  348. end
  349.  
  350. script.Parent.Unequipped:connect(function()
  351.     fireon = false
  352.     ammtxt.Text = ""
  353.     gunimg.Image = 0
  354.     guntxt.Text = "NO WEAPON EQUIPPED"
  355.     guntxt.TextColor3 = Color3.new(255,0,0)
  356.     guntxt.TextStrokeColor3 = Color3.new(162,0,0)
  357. end)
  358. script.Parent.Equipped:connect(on)
  359.  
  360. ---------------------------------------
  361. function raycast(orig33,hitpos33,ignorelist33) --Fire position, Aim Position, Ignored items.
  362.     local origin, frame, ray;
  363.     frame = CFrame.new(orig33, hitpos33)
  364.     ray = Ray.new(frame.p, frame.lookVector * 10)
  365.     local part, hitpos = Workspace:FindPartOnRay(ray, ignorelist33)
  366.     if (part) then
  367.         if part:IsDescendantOf(char) then
  368.             return nil, Vector3.new()  
  369.         end
  370.         if part:findFirstChild("Bouncy") ~= nil then
  371.             if part:findFirstChild("Bouncy").ClassName == "BoolValue" then
  372.                 if part:findFirstChild("Bouncy").Value then
  373.                     return Tool.Handle, Vector3.new()
  374.                 end
  375.             end
  376.         end
  377.         if part:findFirstChild("Ignore") ~= nil then
  378.             if part:findFirstChild("Ignore").ClassName == "BoolValue" then
  379.                 if part:findFirstChild("Ignore").Value then
  380.                     return nil, Vector3.new()
  381.                 end
  382.             end
  383.         end
  384.         if part:findFirstChild("Damage") ~= nil then
  385.             local thp = part:findFirstChild("Damage"):findFirstChild("health")
  386.             local ttm = part:findFirstChild("Damage"):findFirstChild("team")
  387.             if part.Damage.ClassName == "BoolValue" and thp ~= nil and ttm ~= nil then
  388.                 if part:findFirstChild("Damage").Value and check_aggressive(ttm.Value,player.TeamColor) then
  389.                     if Damage > part.Damage:findFirstChild("health").Value then
  390.                         part.Damage:findFirstChild("health").Value = 0
  391.                     else
  392.                         part.Damage:findFirstChild("health").Value = part.Damage:findFirstChild("health").Value - Damage
  393.                     end
  394.                     return part, hitpos
  395.                 end
  396.             end
  397.         end
  398.         return part, hitpos
  399.     else
  400.         return nil, Vector3.new()
  401.     end
  402. end
  403.  
  404. chk = Instance.new("IntValue")
  405. chk.Value = 0
  406. fire_at = Vector3.new()
  407.  
  408. function PreFire(pss)
  409.     for i = 1,Shots_Per_Bullet do
  410.         fire_at = pss
  411.         chk.Value = chk.Value + 1
  412.     end
  413. end
  414.  
  415. chk.Changed:connect(function()
  416.     Fire(fire_at)
  417. end)
  418. chk.Changed:connect(ShakeCam)
  419.  
  420. function Fire(aim)
  421.     local shooting_ray = CFrame.new((Tool.Handle.CFrame * CFrame.new(Shoot_From)).p,aim)
  422.     local Gen_Inacc = Vector3.new(math.random(-Inaccuracy*100,Inaccuracy*100)/100,math.random(-Inaccuracy*100,Inaccuracy*100)/100,math.random(-Inaccuracy*100,Inaccuracy*100)/100)
  423.     local shooting_ray2 = CFrame.new(shooting_ray.p,(shooting_ray * CFrame.new(0,0,-100)).p + Gen_Inacc)
  424.     local lazer_start = shooting_ray2 * CFrame.Angles(math.pi / 2, 0, 0)
  425.     ignoreit = Shots
  426.     local i,a,m,hitted
  427.     local p = shell:clone()
  428.     p.Parent = Shots
  429.     p.CFrame = lazer_start
  430.     hitted = nil
  431.     local cnt = 0
  432.     for i = 1,Distance do
  433.         p.CFrame = lazer_start * CFrame.Angles(bullet_spin.x*math.pi,bullet_spin.y*math.pi,bullet_spin.z*math.pi)
  434.         count_start = (lazer_start * CFrame.new(0,-0.8,0)).p
  435.         count_end = (lazer_start * CFrame.new(0,-1,0)).p
  436.         hitted, hpos = raycast(count_start,count_end,ignoreit)
  437.         lazer_start = lazer_start * CFrame.new(0,-1,0)
  438.         if i*Bullet_Speed > Distance_With_No_Gravity then
  439.             if (lazer_start * CFrame.new(0,-1,0)).p.y - lazer_start.p.y > -0.85 then
  440.                 lazer_start = lazer_start * CFrame.Angles(math.rad(-0.05*Bullet_Gravity), 0, 0)
  441.             end
  442.         end
  443.         if (hitted) then
  444.             break
  445.         end
  446.         cnt = cnt + 1
  447.         if cnt == Bullet_Speed then
  448.             cnt = 0
  449.             wait()
  450.         end
  451.     end
  452.  
  453.     p:remove()
  454.  
  455.     if hitted then
  456.         if not hitted:IsDescendantOf(char) then
  457.             GiveDamage(hitted,Damage,Head_Damage)
  458.         end
  459.     end
  460. end
  461.  
  462. if Automatic then
  463.     while true do
  464.         wait()
  465.         if fireon then
  466.             shot()
  467.         end
  468.     end
  469. end
Advertisement
Add Comment
Please, Sign In to add comment