Advertisement
billwa

Flashbang -wip-

Oct 23rd, 2015
390
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.26 KB | None | 0 0
  1. flashbang = Instance.new("Tool",game.Players.meunumbertwo.Backpack)
  2. flashbang.Name = "FlashBang"
  3.  
  4. handle = Instance.new("Part",flashbang)
  5. handle.FormFactor = Enum.FormFactor.Symmetric
  6. handle.TopSurface = Enum.SurfaceType.Smooth
  7. handle.Size = Vector3.new(1,1,1)
  8. handle.Name = "Handle"
  9. handle.CFrame = CFrame.new(-68,0.49829688668251,-7) * CFrame.Angles(5.8255799369435e-018, 1.5707963705063, 0)
  10. handle.BrickColor = BrickColor.new("Earth green")
  11. handle.Friction = 0.30000001192093
  12. handle.Shape = Enum.PartType.Ball
  13. handle.BottomSurface = Enum.SurfaceType.Smooth
  14.  
  15. creator = Instance.new("ObjectValue",handle)
  16. creator.Name = "creator"
  17.  
  18. fire = Instance.new("Fire",handle)
  19. fire.Enabled = false
  20. fire.Heat = 0
  21. fire.Color = Color3.new(1, 1, 1)
  22. fire.SecondaryColor = Color3.new(1, 1, 1)
  23. fire.Size = 30
  24.  
  25. boom = Instance.new("Sound",handle)
  26. boom.Pitch = 2
  27. boom.Name = "Boom"
  28. boom.Volume = 1
  29. boom.SoundId = "http://www.roblox.com/asset/?id=25270310"
  30.  
  31. smoke = Instance.new("Smoke",handle)
  32. smoke.Enabled = false
  33. smoke.RiseVelocity = 0
  34. smoke.Size = 100
  35.  
  36. sparkles = Instance.new("Sparkles",handle)
  37. sparkles.Enabled = false
  38. sparkles.SparkleColor = Color3.new(1, 1, 1)
  39.  
  40. mesh = Instance.new("SpecialMesh",handle)
  41. mesh.Scale = Vector3.new(0.60000002384186,0.69999998807907,0.60000002384186)
  42. mesh.MeshId = "http://www.roblox.com/asset/?id=16975131"
  43. mesh.TextureId = "http://www.roblox.com/asset/?id=16975111"
  44. mesh.MeshType = Enum.MeshType.FileMesh
  45.  
  46. counter = Instance.new("NumberValue",flashbang)
  47. counter.Name = "Counter"
  48. counter.Value = 7
  49.  
  50. blind = Instance.new("GuiMain",flashbang)
  51. blind.Name = "Blind"
  52.  
  53. blur = Instance.new("ImageLabel",blind)
  54. blur.Size = UDim2.new(100000000, 0, 1000000, 2000)
  55. blur.BorderColor3 = Color3.new(0.105882, 0.164706, 0.207843)
  56. blur.Name = "Blur"
  57. blur.BackgroundColor3 = Color3.new(1, 1, 1)
  58.  
  59. local Tool = flashbang;
  60.  
  61. enabled = true
  62. function onButton1Down(mouse)
  63.     if not enabled then
  64.         return
  65.     end
  66.  
  67.     enabled = false
  68.     mouse.Icon = "rbxasset://textures\\GunWaitCursor.png"
  69.  
  70.     wait(1)
  71.     mouse.Icon = "rbxasset://textures\\GunCursor.png"
  72.     enabled = true
  73.  
  74. end
  75.  
  76. function Mode(k)
  77. if (k == "r") then
  78. Tool.Counter.Value = 1
  79. end
  80. if (k == "e") then
  81. Tool.Counter.Value = 4
  82. end
  83. if (k == "q") then
  84. Tool.Counter.Value = 7
  85. end
  86. if (k == "f") then
  87. Tool.Counter.Value = 11
  88. end
  89. end
  90.  
  91. function onEquippedLocal(mouse)
  92.  
  93.     if mouse == nil then
  94.         print("Mouse not found")
  95.         return
  96.     end
  97.  
  98.     mouse.Icon = "rbxasset://textures\\GunCursor.png"
  99.     mouse.Button1Down:connect(function() onButton1Down(mouse) end)
  100.     mouse.KeyDown:connect(Mode)
  101. end
  102.  
  103. Tool.Equipped:connect(onEquippedLocal)
  104.  
  105. print("Wearing Off")
  106.  
  107. local Tool = flashbang
  108. local ToolName = Tool.Name
  109. local VELOCITY = 70
  110. local armed = false
  111. local db = false
  112.  
  113. function Throw(mouse_pos)
  114.     local vCharacter = Tool.Parent
  115.     local vPlayer = game.Players:playerFromCharacter(vCharacter)
  116.     local head = vCharacter:findFirstChild("Head")
  117.     if head == nil then return end
  118.     local dir = mouse_pos - head.Position
  119.     dir = computeDirection(dir)
  120.     local launch = head.Position + 5 * dir
  121.     local delta = mouse_pos - launch
  122.     local dy = delta.y
  123.     local new_delta = Vector3.new(delta.x, 0, delta.z)
  124.     delta = new_delta
  125.     local dx = delta.magnitude
  126.     local unit_delta = delta.unit
  127.     -- acceleration due to gravity in RBX units
  128.     local g = (-9.81 * 20)
  129.     local theta = computeLaunchAngle( dx, dy, g)
  130.     local vy = math.sin(theta)
  131.     local xz = math.cos(theta)
  132.     local vx = unit_delta.x * xz
  133.     local vz = unit_delta.z * xz
  134.     Tool.Parent = workspace
  135.     local missile = Tool.Handle
  136.     missile.Position = launch
  137.     missile.Velocity = Vector3.new(vx,vy,vz) * VELOCITY
  138.     local creator_tag = Instance.new("ObjectValue")
  139.     creator_tag.Value = vPlayer
  140.     creator_tag.Name = "creator"
  141.     creator_tag.Parent = missile
  142. end
  143.  
  144. function computeLaunchAngle(dx,dy,grav)
  145.     local g = math.abs(grav)
  146.     local inRoot = (VELOCITY^4) - (g * ((g*dx*dx) + (2*dy*VELOCITY*VELOCITY)))
  147.     if inRoot <= 0 then
  148.         return .25 * math.pi
  149.     end
  150.     local root = math.sqrt(inRoot)
  151.     local inATan1 = ((VELOCITY*VELOCITY) + root) / (g*dx)
  152.     local inATan2 = ((VELOCITY*VELOCITY) - root) / (g*dx)
  153.     local answer1 = math.atan(inATan1)
  154.     local answer2 = math.atan(inATan2)
  155.     if answer1 < answer2 then return answer1 end
  156.     return answer2
  157. end
  158.  
  159. function computeDirection(vec)
  160.     local lenSquared = vec.magnitude * vec.magnitude
  161.     local invSqrt = 1 / math.sqrt(lenSquared)
  162.     return Vector3.new(vec.x * invSqrt, vec.y * invSqrt, vec.z * invSqrt)
  163. end
  164.  
  165. Tool.Enabled = true
  166. function onActivated()
  167.     if (armed) then
  168.     local character = Tool.Parent;
  169.     local humanoid = character.Humanoid
  170.     if humanoid == nil then
  171.         print("Humanoid not found")
  172.         return
  173.     end
  174.     local targetPos = humanoid.TargetPoint
  175.     Throw(targetPos)
  176.     else
  177.     Arm()
  178.     end
  179. end
  180.  
  181. function Arm()
  182. local count = Tool.Counter.Value
  183. print("Arming grenade...")
  184. armed = true
  185. coroutine.resume(coroutine.create(function()
  186. for i = 1,count do
  187. Tool.Name = ToolName.. " [" ..count.. "]"
  188. print(count.. "...")
  189. wait(1)
  190. count = count - 1
  191. end
  192.     for i,p in pairs(game.Players:children()) do
  193.     if (p.Character) and (p.Character:findFirstChild("Torso")) and ((p.Character.Torso.Position - Tool.Handle.Position).magnitude < 50) then
  194.     local stun = Tool.Blind:Clone()
  195.     stun.Parent = p.PlayerGui
  196.     wait()
  197.     end
  198. end
  199.  
  200. print("BOOM!")
  201. Tool.Handle.Boom:Play()
  202. Tool.Handle.Fire.Enabled = true
  203. Tool.Handle.Smoke.Enabled = true
  204. Tool.Handle.Sparkles.Enabled = true
  205. wait(0.4)
  206. Tool:Remove()
  207. end))
  208. end
  209.  
  210. function Give(part)
  211. wait()
  212. if (part == nil) then return end
  213. if (part.Parent:findFirstChild("Humanoid")) and (part.Parent.Humanoid.Health > 0) and (not db) then
  214. db = true
  215. Tool.Parent = part.Parent
  216. wait(0.5)
  217. db = false
  218. end
  219. end
  220.  
  221. Tool.Activated:connect(onActivated)
  222. Tool.Handle.Touched:connect(Give)
  223.  
  224.  
  225. local light = flashbang
  226.  
  227. wait(2)
  228. while true do
  229.  
  230.         wait(4)  
  231.  
  232.         light.Transparency = .1
  233.    
  234.         wait(1)
  235.  
  236.         light.Transparency = .2
  237.  
  238.         wait(1)
  239.  
  240.         light.Transparency = .2
  241.  
  242.         wait(1)
  243.  
  244.         light.Transparency = .3
  245.  
  246.         wait(1)
  247.  
  248.         light.Transparency = .4
  249.  
  250.         wait(1)
  251.  
  252.         light.Transparency = .5
  253.  
  254.         wait(1)
  255.  
  256.         light.Transparency = .6
  257.  
  258.         wait(1)
  259.  
  260.         light.Transparency = .7
  261.        
  262.         wait(1)
  263.  
  264.         light.Transparency = .8
  265.  
  266.         wait(1)
  267.  
  268.         light.Transparency = .9
  269.  
  270.         wait(1)
  271.  
  272.         light.Transparency = 1
  273.  
  274.         wait(1)
  275.  
  276.         light.Parent:Remove()
  277.  
  278. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement