Advertisement
NightGamingVN

pistol

Mar 20th, 2020
1,175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 13.47 KB | None | 0 0
  1. -- half life 2 pistol by pdnghiaqoi [ marseio ]
  2. Tool0 = Instance.new("Tool")
  3. Part1 = Instance.new("Part")
  4. SpecialMesh2 = Instance.new("SpecialMesh")
  5. Part3 = Instance.new("Part")
  6. Weld4 = Instance.new("Weld")
  7. CFrameValue5 = Instance.new("CFrameValue")
  8. RemoteEvent6 = Instance.new("RemoteEvent")
  9. Tool0.Name = "Pistol"
  10. Part1.Name = "Handle"
  11. Part1.Parent = Tool0
  12. Part1.CFrame = CFrame.new(4.98471212, 0.643921375, -106.679169, 0.993052185, -0.0983180925, -0.0646604076, 0.0347954556, -0.279577047, 0.959492564, -0.112413041, -0.955076039, -0.274213552)
  13. Part1.Orientation = Vector3.new(-73.6399994, -166.729996, 172.910004)
  14. Part1.Position = Vector3.new(4.98471212, 0.643921375, -106.679169)
  15. Part1.Rotation = Vector3.new(-105.949997, -3.71000004, 5.6500001)
  16. Part1.Color = Color3.new(0.0666667, 0.0666667, 0.0666667)
  17. Part1.Velocity = Vector3.new(-0.0186361074, -0.0172049999, -0.184608459)
  18. Part1.Size = Vector3.new(0.160000294, 0.160000294, 0.160000294)
  19. Part1.BrickColor = BrickColor.new("Really black")
  20. Part1.Material = Enum.Material.Metal
  21. Part1.RotVelocity = Vector3.new(-3.34376526, 0.0179910939, 0.337135613)
  22. Part1.brickColor = BrickColor.new("Really black")
  23. Part1.Shape = Enum.PartType.Ball
  24. SpecialMesh2.Parent = Part1
  25. SpecialMesh2.MeshId = "rbxassetid://430054076"
  26. SpecialMesh2.Scale = Vector3.new(0.100000001, 0.100000001, 0.100000001)
  27. SpecialMesh2.VertexColor = Vector3.new(2, 2, 2)
  28. SpecialMesh2.TextureId = "rbxassetid://430054077"
  29. SpecialMesh2.MeshType = Enum.MeshType.FileMesh
  30. Part3.Name = "ShootPos"
  31. Part3.Parent = Part1
  32. Part3.CFrame = CFrame.new(4.98253918, 0.0975679979, -106.699265, 0.993052185, -0.0983180925, -0.0646604076, 0.0347954556, -0.279577047, 0.959492564, -0.112413041, -0.955076039, -0.274213552)
  33. Part3.Orientation = Vector3.new(-73.6399994, -166.729996, 172.910004)
  34. Part3.Position = Vector3.new(4.98253918, 0.0975679979, -106.699265)
  35. Part3.Rotation = Vector3.new(-105.949997, -3.71000004, 5.6500001)
  36. Part3.Transparency = 1
  37. Part3.Velocity = Vector3.new(0.165197536, -0.0851332992, 1.64230812)
  38. Part3.Size = Vector3.new(0.140000001, 0.200000003, 0.140000001)
  39. Part3.CanCollide = false
  40. Part3.Material = Enum.Material.Metal
  41. Part3.Reflectance = 0.10000000149012
  42. Part3.RotVelocity = Vector3.new(-3.34376526, 0.0179910939, 0.337135613)
  43. Weld4.Name = "qCFrameWeldThingy"
  44. Weld4.Parent = Part3
  45. Weld4.C1 = CFrame.new(0.0189089775, -0.172157973, 0.518569946, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  46. Weld4.Part0 = Part1
  47. Weld4.Part1 = Part3
  48. Weld4.part1 = Part3
  49. CFrameValue5.Name = "qRelativeCFrameWeldValue"
  50. CFrameValue5.Parent = Part3
  51. CFrameValue5.Value = CFrame.new(0.0189089775, -0.172157973, 0.518569946, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  52. RemoteEvent6.Name = "MainRemote"
  53. BaseShot = Instance.new("Part")
  54. BaseShot.Name = "Bullet"
  55. BaseShot.BrickColor = BrickColor.new("New Yeller")
  56. BaseShot.Material = Enum.Material.Metal
  57. BaseShot.Shape = Enum.PartType.Block
  58. BaseShot.TopSurface = Enum.SurfaceType.Smooth
  59. BaseShot.BottomSurface = Enum.SurfaceType.Smooth
  60. BaseShot.FormFactor = Enum.FormFactor.Custom
  61. BaseShot.Size = Vector3.new(0.05, 0.05, 3)
  62. BaseShot.CanCollide = false
  63. BaseShot.Locked = true
  64. local a = NLS([[
  65. ScreenGui0 = Instance.new("ScreenGui")
  66. ImageLabel1 = Instance.new("ImageLabel")
  67. TextLabel2 = Instance.new("TextLabel")
  68. TextLabel3 = Instance.new("TextLabel")
  69. TextLabel4 = Instance.new("TextLabel")
  70. ScreenGui0.Parent = mas
  71. ScreenGui0.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
  72. ImageLabel1.Name = "Amno"
  73. ImageLabel1.Parent = ScreenGui0
  74. ImageLabel1.Position = UDim2.new(1, -175, 1, -75)
  75. ImageLabel1.Size = UDim2.new(0, 150, 0, 50)
  76. ImageLabel1.BackgroundColor = BrickColor.new("Really black")
  77. ImageLabel1.BackgroundColor3 = Color3.new(0, 0, 0)
  78. ImageLabel1.BackgroundTransparency = 1
  79. ImageLabel1.Image = "http://www.roblox.com/asset/?id=882669350"
  80. ImageLabel1.ImageColor3 = Color3.new(0, 0, 0)
  81. ImageLabel1.ImageTransparency = 0.89999997615814
  82. TextLabel2.Name = "UsingAmno"
  83. TextLabel2.Parent = ImageLabel1
  84. TextLabel2.Position = UDim2.new(0, 55, 0, 0)
  85. TextLabel2.Size = UDim2.new(0, 45, 0, 50)
  86. TextLabel2.BackgroundColor = BrickColor.new("Institutional white")
  87. TextLabel2.BackgroundColor3 = Color3.new(1, 1, 1)
  88. TextLabel2.BackgroundTransparency = 1
  89. TextLabel2.Font = Enum.Font.SourceSansLight
  90. TextLabel2.FontSize = Enum.FontSize.Size28
  91. TextLabel2.Text = "8"
  92. TextLabel2.TextColor = BrickColor.new("New Yeller")
  93. TextLabel2.TextColor3 = Color3.new(1, 1, 0)
  94. TextLabel2.TextScaled = true
  95. TextLabel2.TextSize = 25
  96. TextLabel2.TextStrokeColor3 = Color3.new(0.709804, 0.709804, 0)
  97. TextLabel2.TextTruncate = Enum.TextTruncate.AtEnd
  98. TextLabel2.TextWrap = true
  99. TextLabel2.TextWrapped = true
  100. TextLabel2.TextXAlignment = Enum.TextXAlignment.Left
  101. TextLabel2.TextYAlignment = Enum.TextYAlignment.Bottom
  102. TextLabel3.Name = "Text"
  103. TextLabel3.Parent = ImageLabel1
  104. TextLabel3.Position = UDim2.new(0, 5, 1, -33)
  105. TextLabel3.Size = UDim2.new(0, 50, 0, 35)
  106. TextLabel3.BackgroundColor = BrickColor.new("Institutional white")
  107. TextLabel3.BackgroundColor3 = Color3.new(1, 1, 1)
  108. TextLabel3.BackgroundTransparency = 1
  109. TextLabel3.Font = Enum.Font.SourceSansSemibold
  110. TextLabel3.FontSize = Enum.FontSize.Size14
  111. TextLabel3.Text = "AMMO"
  112. TextLabel3.TextColor = BrickColor.new("New Yeller")
  113. TextLabel3.TextColor3 = Color3.new(1, 1, 0)
  114. TextLabel3.TextSize = 14
  115. TextLabel3.TextStrokeColor3 = Color3.new(0.635294, 0.635294, 0)
  116. TextLabel3.TextWrap = true
  117. TextLabel3.TextWrapped = true
  118. TextLabel4.Name = "StoringAmno"
  119. TextLabel4.Parent = ImageLabel1
  120. TextLabel4.Position = UDim2.new(1, -75, 0.5, -25)
  121. TextLabel4.Size = UDim2.new(0, 60, 0, 45)
  122. TextLabel4.BackgroundColor = BrickColor.new("Institutional white")
  123. TextLabel4.BackgroundColor3 = Color3.new(1, 1, 1)
  124. TextLabel4.BackgroundTransparency = 1
  125. TextLabel4.Font = Enum.Font.SourceSansLight
  126. TextLabel4.FontSize = Enum.FontSize.Size28
  127. TextLabel4.Text = "250"
  128. TextLabel4.TextColor = BrickColor.new("New Yeller")
  129. TextLabel4.TextColor3 = Color3.new(1, 1, 0)
  130. TextLabel4.TextSize = 25
  131. TextLabel4.TextStrokeColor3 = Color3.new(0.709804, 0.709804, 0)
  132. TextLabel4.TextTruncate = Enum.TextTruncate.AtEnd
  133. TextLabel4.TextWrap = true
  134. TextLabel4.TextWrapped = true
  135. TextLabel4.TextXAlignment = Enum.TextXAlignment.Right
  136. TextLabel4.TextYAlignment = Enum.TextYAlignment.Bottom
  137. Settings = {
  138.     Remote = script:WaitForChild("MainRemote");
  139.     Tool = script.Parent;
  140.     AmnoSettings = {
  141.         Amno = 18;
  142.         MaxAmno = 18  ;
  143.         Storing = math.huge;
  144.         MaxStoring = math.huge;
  145.     };
  146.     GUI = {
  147.         SG = ScreenGui0;
  148.         Children = {}; 
  149.     };
  150.     Cooldown = {
  151.         Delay = false;
  152.         Reloading = false;
  153.     };
  154.     Break = false;
  155. };
  156. for i,v in pairs(Settings.GUI.SG:GetDescendants()) do
  157.     Settings.GUI.Children[v.Name] = v
  158. end
  159. game:GetService("RunService").RenderStepped:Connect(function()
  160.     if Settings.GUI.Children.UsingAmno.Text ~= Settings.AmnoSettings.Amno then
  161.         Settings.GUI.Children.UsingAmno.Text = Settings.AmnoSettings.Amno
  162.     end
  163.     if Settings.GUI.Children.StoringAmno.Text ~= Settings.AmnoSettings.Storing then
  164.         Settings.GUI.Children.StoringAmno.Text = Settings.AmnoSettings.Storing
  165.     end
  166. end)
  167. TS = game:GetService("TweenService")
  168. CurrentTween = {}
  169. CurrentTween1 = {}
  170. function Disable(GUI)
  171.     GUI.ImageTransparency = 1
  172.     local a = TweenInfo.new(.25,Enum.EasingStyle.Quad,Enum.EasingDirection.Out)
  173.     for i,v in pairs(GUI:GetDescendants()) do
  174.         local b = {}
  175.         if CurrentTween[v] then CurrentTween[v]:Cancel() end
  176.         if v:IsA("ImageLabel") or v:IsA("ImageButton") then
  177.             b.ImageTransparency = 1
  178.         elseif v:IsA("TextLabel") or v:IsA("TextButton") then
  179.             b.TextTransparency = 1
  180.         elseif v:IsA("Frame") and v.Parent ~= GUI then
  181.             b.BackgroundTransparency = 1
  182.         end
  183.         CurrentTween[v] = TS:Create(v,a,b)
  184.         CurrentTween[v]:Play()
  185.     end
  186. end
  187. function Enable(GUI)
  188.     GUI.ImageTransparency = 0.9
  189.     local a = TweenInfo.new(.25,Enum.EasingStyle.Quad,Enum.EasingDirection.Out)
  190.     for i,v in pairs(GUI:GetDescendants()) do
  191.         local b = {}
  192.         if CurrentTween[v] then CurrentTween[v]:Cancel() end
  193.         if v:IsA("ImageLabel") or v:IsA("ImageButton") then
  194.             b.ImageTransparency = 0.9
  195.         elseif v:IsA("TextLabel") or v:IsA("TextButton") then
  196.             b.TextTransparency = 0
  197.         elseif v:IsA("Frame") and v.Parent ~= GUI then
  198.             b.BackgroundTransparency = 0
  199.         end
  200.         CurrentTween[v] = TS:Create(v,a,b)
  201.         CurrentTween[v]:Play()
  202.     end
  203. end
  204. function AmnoChangeBloom()
  205.     if Settings.GUI.Children.Amno.ImageTransparency > 0.9 then return end
  206.     spawn(function()
  207.     Settings.GUI.Children.UsingAmno.TextStrokeTransparency = 0.5
  208.     local ti = TweenInfo.new(
  209.         1,
  210.         Enum.EasingStyle.Quad,
  211.         Enum.EasingDirection.Out
  212.     )
  213.     local a
  214.     local t
  215.     if Settings.AmnoSettings.Amno <= 0 and Settings.AmnoSettings.Storing <= 0 then
  216.         Settings.GUI.Children.Amno.ImageTransparency = 0.4
  217.         Settings.GUI.Children.Amno.ImageColor3 = Color3.new(170,0,0)
  218.         Settings.GUI.Children.UsingAmno.TextColor3 = Color3.new(170,0,0)
  219.         Settings.GUI.Children.UsingAmno.TextStrokeColor3 = Color3.new(107,0,0)
  220.         Settings.GUI.Children.StoringAmno.TextColor3 = Color3.new(170,0,0)
  221.     else
  222.         Settings.GUI.Children.Amno.ImageTransparency = 0.9
  223.         Settings.GUI.Children.Amno.ImageColor3 = Color3.new(0,0,0)
  224.         Settings.GUI.Children.UsingAmno.TextColor3 = Color3.new(255,255,0)
  225.         Settings.GUI.Children.UsingAmno.TextStrokeColor3 = Color3.new(181,181,0)
  226.         Settings.GUI.Children.StoringAmno.TextColor3 = Color3.new(255,255,0)
  227.     end
  228.     t = TS:Create(Settings.GUI.Children.UsingAmno,ti,{TextStrokeTransparency = 1})
  229.     t:Play()
  230.     local b
  231.     b = game:GetService("RunService").Heartbeat:Connect(function()
  232.         if Settings.Break then
  233.             if a then a:Cancel() end
  234.             if t then t:Cancel() end
  235.             Settings.GUI.Children.UsingAmno.TextStrokeTransparency = 1
  236.             b:Disconnect()
  237.         end
  238.     end)
  239.     end)
  240. end
  241. function Reloading()
  242.     if Settings.Cooldown.Reloading or Settings.AmnoSettings.Amno == Settings.AmnoSettings.MaxAmno then return end
  243.     Settings.Cooldown.Reloading = true
  244.     Settings.Remote:FireServer("Reload")
  245.     spawn(function()
  246.         wait(2.69)
  247.         AmnoChangeBloom()
  248.         Settings.AmnoSettings.Amno = Settings.AmnoSettings.MaxAmno
  249.         Settings.Cooldown.Reloading = false
  250.     end)
  251. end
  252. Settings.Tool.Equipped:Connect(function(Mouse)
  253.     Settings.GUI.SG.Parent = owner:FindFirstChildOfClass("PlayerGui")
  254.     Enable(Settings.GUI.Children.Amno)
  255.     Mouse.Button1Down:Connect(function()
  256.         if Settings.AmnoSettings.Amno > 0 then
  257.             if not Settings.Cooldown.Delay and not Settings.Cooldown.Reloading then
  258.                 spawn(function()
  259.                     Settings.Cooldown.Delay = true
  260.                     wait(.1)
  261.                     Settings.Cooldown.Delay = false
  262.                 end)
  263.                 AmnoChangeBloom()
  264.                 Settings.Remote:FireServer("Shoot",Mouse.Hit.p)
  265.                 Settings.AmnoSettings.Amno = Settings.AmnoSettings.Amno - 1
  266.             end
  267.         else
  268.             Reloading()
  269.         end
  270.     end)
  271.     Mouse.KeyDown:Connect(function(Key)
  272.         if Key == "r" then
  273.             Reloading()
  274.         end
  275.     end)
  276. end)
  277. Settings.Tool.Unequipped:Connect(function()
  278.     Disable(Settings.GUI.Children.Amno)
  279. end)
  280. ]],Tool0)
  281. Settings = {
  282.     Tool = Tool0;
  283.     Client = a;
  284.     Speed = 500;
  285.     Duration = 5;
  286.     Remote = RemoteEvent6;
  287.     Children = {};
  288.     Damage = {
  289.         Min = 5;
  290.         Max = 8;
  291.     };
  292.     Character = owner.Character;
  293.     Humanoid = owner.Character:FindFirstChildOfClass("Humanoid");
  294. }
  295. for i,v in pairs(Tool0:GetDescendants()) do
  296.     Settings.Children[v.Name] = v
  297. end
  298. local function FindCharacterAncestor(subject)
  299.     if subject and subject ~= workspace then
  300.         local humanoid = subject:FindFirstChildOfClass('Humanoid')
  301.         if humanoid then
  302.             return subject, humanoid
  303.         else
  304.             return FindCharacterAncestor(subject.Parent)
  305.         end
  306.     end
  307.     return nil
  308. end
  309. function CalculateDamage(Hit,Min,Max)
  310.     if Hit.Name == "Head" then
  311.         Min = Min*1.5
  312.         Max = Max*2.15
  313.     elseif string.match(Hit.Name,"Leg") then
  314.         Min = Min/1.25
  315.         Max = Max/1.5
  316.     elseif string.match(Hit.Name,"Hand") then
  317.         Min = Min/1.15
  318.         Max = Max/1.05
  319.     end
  320.     return Min,Max
  321. end
  322. function MakeSound(Id)
  323.     local Sound = Instance.new("Sound")
  324.     Sound.Volume = 1
  325.     Sound.Pitch = 1
  326.     Sound.Looped = false
  327.     Sound.Parent = Settings.Children.Handle
  328.     Sound.MaxDistance = 100
  329.     Sound.EmitterSize = 50
  330.     Sound.SoundId = "rbxassetid://"..Id
  331.     Sound:Play()
  332.     return Sound
  333. end
  334. function OnTouched(Projectile, Hit)
  335.     if not Hit or not Hit.Parent then
  336.         return
  337.     end
  338.     local character, humanoid = FindCharacterAncestor(Hit)
  339.     if character and humanoid and character ~= Settings.Character then
  340.         if humanoid.MaxHealth > 50000 then humanoid.MaxHealth = 50000 end
  341.         local min,max = CalculateDamage(Hit,Settings.Damage.Min,Settings.Damage.Max)
  342.         min = min * (humanoid.MaxHealth / 100)
  343.         max = max * (humanoid.MaxHealth / 100)
  344.         humanoid.Health = humanoid.Health - math.random(min,max)
  345.         if Projectile and Projectile.Parent then
  346.             Projectile:Destroy()
  347.         end
  348.     end
  349. end
  350. function Fire(Target)
  351.     if Settings.Humanoid.Health <= 0 then return end
  352.     MakeSound(1215330166)
  353.     local handleCFrame = Settings.Children.ShootPos.CFrame
  354.     local firingPoint = handleCFrame.p
  355.     local shotCFrame = CFrame.new(firingPoint, Target)
  356.     local laserShotClone = BaseShot:Clone()
  357.     laserShotClone.CFrame = shotCFrame + (shotCFrame.lookVector * (BaseShot.Size.Z / 2))
  358.     local bodyVelocity = Instance.new('BodyVelocity')
  359.     bodyVelocity.velocity = shotCFrame.lookVector * Settings.Speed
  360.     bodyVelocity.Parent = laserShotClone
  361.     laserShotClone.Touched:connect(function(otherPart)
  362.         OnTouched(laserShotClone, otherPart)
  363.     end)
  364.     game:GetService("Debris"):AddItem(laserShotClone, Settings.Duration)
  365.     laserShotClone.Parent = Settings.Tool
  366. end
  367. Settings.Remote.OnServerEvent:Connect(function(player,typ,data)
  368.     if player == owner then
  369.         if typ == "Shoot" then
  370.             Fire(data)
  371.         elseif typ == "Reload" then
  372.             MakeSound(249080513)
  373.         end
  374.     end
  375. end)
  376. Tool0.Parent = owner:FindFirstChildOfClass("Backpack")
  377. Settings.Remote.Parent = Settings.Client
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement