Advertisement
Sir_Barcendo

gun

Mar 18th, 2023 (edited)
738
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.88 KB | None | 0 0
  1. local char = owner.Character
  2. local tool = Instance.new("Tool")
  3. local holding = false
  4. local db = false
  5. local remote = Instance.new("RemoteEvent")
  6. remote.Name = "Shoot"
  7. remote.Parent = tool
  8. tool.Parent = owner.Backpack
  9. tool.Name = "Tommy Gun"
  10. tool.Grip = CFrame.new(0,-.6,.5)
  11.  
  12. local sound = Instance.new("Sound")
  13. local particle = Instance.new("ParticleEmitter")
  14.  
  15. local handle = Instance.new("Part")
  16. handle.Name = "Handle"
  17. handle.Parent = tool
  18.  
  19. local att = Instance.new("Attachment")
  20. att.Parent = handle
  21. att.Position = Vector3.new(0,.18,-2)
  22.  
  23. sound.Parent = att
  24. sound.Volume = 0.5
  25. sound.SoundId = "rbxassetid://5238024665"
  26.  
  27. particle.Parent = att
  28. particle.Texture = "rbxassetid://7924475328"
  29. particle.Enabled = true
  30. particle.Size = NumberSequence.new(1)
  31. particle.Lifetime = NumberRange.new(1)
  32. particle.Transparency = NumberSequence.new(0)
  33. particle.Speed = NumberRange.new(0)
  34. particle.Shape = Enum.ParticleEmitterShape.Box
  35. particle.EmissionDirection = Enum.NormalId.Front
  36. particle.Color = ColorSequence.new(BrickColor.new("Gold").Color)
  37. particle.LightEmission = 1
  38. particle.LightInfluence = 1
  39. particle.LockedToPart = true
  40. particle.Drag = 0
  41. particle.VelocitySpread = NumberRange.new(0, 0)
  42. particle.VelocityInheritance = 0
  43. particle.Acceleration = Vector3.new(0, 0, 0)
  44. particle.SpreadAngle = Vector2.new(0, 0)
  45. particle.ZOffset = 2
  46. particle.Rotation = NumberRange.new(0, 360)
  47. particle.RotSpeed = NumberRange.new(0)
  48. particle.Rate = 100
  49.  
  50. local mesh = Instance.new("SpecialMesh")
  51. mesh.Parent = handle
  52. mesh.Scale = Vector3.new(0.9,0.9,0.9)
  53. mesh.MeshId = "http://www.roblox.com/asset/?id=116679805"
  54. mesh.TextureId = "http://www.roblox.com/asset/?id=116679995"
  55.  
  56. NLS([[
  57.     local char = owner.Character
  58.     local tool = script.Parent
  59.     local event = tool.Shoot
  60.     local mouse = game.Players.LocalPlayer:GetMouse()
  61.    
  62.     tool.Activated:Connect(function()
  63.     holding = true
  64.     end)
  65.  
  66. tool.Deactivated:Connect(function()
  67.     holding = false
  68. end)
  69.     spawn(function()
  70.         while wait() do
  71.             if holding then
  72.                 if not db then
  73.                     db = true
  74.                    
  75.                     print("shoot")
  76.                    
  77.     event:FireServer(mouse.Hit.Position)
  78.                    
  79.                     wait(.1)
  80.                    
  81.                     db = false
  82.                 end
  83.             end
  84.         end
  85. end)
  86.     ]],tool)
  87.  
  88. remote.OnServerEvent:Connect(function(player,pos)
  89.                    
  90.      local beam = Instance.new("Part")
  91.          beam.Parent = char
  92.             beam.Anchored = true
  93.             beam.CanCollide = false
  94.           beam.CFrame = CFrame.new(att.WorldPosition,pos) * CFrame.new(0, 0, -(att.WorldPosition-pos).Magnitude / 2)
  95.            beam.Size = Vector3.new(.1,.1,(att.WorldPosition-pos).Magnitude)
  96.         beam.BrickColor = BrickColor.new("Gold")
  97.         beam.Material = Enum.Material.Neon
  98.        
  99.         local params = OverlapParams.new()
  100.         params.FilterDescendantsInstances = {char}
  101.         params.FilterType = Enum.RaycastFilterType.Blacklist
  102.        
  103.         sound:Play()
  104.         particle:Emit(100)
  105.        
  106.         local parts = workspace:GetPartBoundsInBox(CFrame.new(pos),Vector3.new(.2,.2,.2),params)
  107.        
  108.         for i,v in pairs(parts) do
  109.             if v.Parent then
  110.                 if v:FindFirstAncestorOfClass("Model") then
  111.                     local pchar = v:FindFirstAncestorOfClass("Model")
  112.                    
  113.                     if pchar:FindFirstChild("Humanoid") then
  114.                         pchar.Humanoid:TakeDamage(5)
  115.                     end
  116.                 end
  117.             end
  118.         end
  119.        
  120.         spawn(function()
  121.              for i = 1,10,1 do
  122.                     beam.Transparency += 0.1
  123.                    
  124.                     wait(0.025)
  125.              end
  126.                
  127.                 beam:Destroy()
  128.         end)
  129.        
  130. end)
  131.  
  132.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement