DANIOS

concussion grenade

Apr 1st, 2017
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.98 KB | None | 0 0
  1. --[[
  2. Concussion Grenade
  3. When it explodes, it sends out an explosive shockwave, pushing parts away and causing damage.
  4. --]]
  5.  
  6.  
  7. if script == nil then return end
  8.  
  9.  
  10. ModelName = "Conc. Grenade"
  11. Player = Game.Players.LocalPlayer
  12. Selected = false
  13. Connected = false
  14. Button1Down = false
  15. CanUse = true
  16. Primed = false
  17. Thrown = false
  18.  
  19.  
  20. function CheckPlayer()
  21. if Player.Character == nil then return false end
  22. if Player.Character:FindFirstChild("Torso") == nil or Player.Character:FindFirstChild("Right Arm") == nil or Player.Character:FindFirstChild("Humanoid") == nil then return false end
  23. if Player.Character.Humanoid.Health <= 0 then return false end
  24. return true
  25. end
  26.  
  27. function tagHumanoid(humanoid)
  28. local tag = Instance.new("ObjectValue")
  29. tag.Name = "creator"
  30. tag.Value = Player
  31. tag.Parent = humanoid
  32. local tag = Instance.new("StringValue")
  33. tag.Name = "creatorType1"
  34. tag.Value = ModelName
  35. tag.Parent = humanoid
  36. local tag = Instance.new("StringValue")
  37. tag.Name = "creatorType2"
  38. tag.Value = "shot"
  39. tag.Parent = humanoid
  40. end
  41.  
  42. function untagHumanoid(humanoid)
  43. if humanoid ~= nil then
  44. local tag = humanoid:FindFirstChild("creator")
  45. if tag ~= nil then
  46. tag:Remove()
  47. end
  48. local tag = humanoid:FindFirstChild("creatorType1")
  49. if tag ~= nil then
  50. tag:Remove()
  51. end
  52. local tag = humanoid:FindFirstChild("creatorType2")
  53. if tag ~= nil then
  54. tag:Remove()
  55. end
  56. end
  57. end
  58.  
  59.  
  60.  
  61. function CreateParts(Parent, Format)
  62. if Parent == nil then return end
  63. local Parts = Instance.new("Model")
  64. Parts.Name = ModelName
  65. if Format == 1 then
  66. Parts.Name = Parts.Name.. " (Holstered)"
  67. end
  68. Parts.Parent = Parent
  69.  
  70. local MasterPart = Instance.new("Part")
  71. MasterPart.Name = "Handle"
  72. MasterPart.BrickColor = BrickColor.new("Really red")
  73. MasterPart.TopSurface = 0
  74. MasterPart.BottomSurface = 0
  75. MasterPart.Shape = "Ball"
  76. MasterPart.FormFactor = "Custom"
  77. MasterPart.Size = Vector3.new(1, 1, 1)
  78. MasterPart.Parent = Parts
  79. local Mesh = Instance.new("SpecialMesh")
  80. Mesh.MeshType = "Sphere"
  81. Mesh.Scale = Vector3.new(0.8, 1, 0.8)
  82. Mesh.Parent = MasterPart
  83. local Weld = Instance.new("Weld")
  84. Weld.Part0 = MasterPart
  85. if Format == 1 then
  86. Weld.Part1 = Player.Character:FindFirstChild("Left Leg")
  87. Weld.C0 = CFrame.new(-0.45, 0, -0.8) * CFrame.fromEulerAnglesXYZ(0, 0, math.rad(90))
  88. elseif Format == 2 then
  89. Weld.Part1 = Player.Character:FindFirstChild("Right Arm")
  90. Weld.C0 = CFrame.new(-1.2, 0, 0) * CFrame.fromEulerAnglesXYZ(math.rad(90), 0, math.rad(90))
  91. end
  92. Weld.Parent = Weld.Part0
  93.  
  94. local Part = Instance.new("Part")
  95. Part.Name = "Pin Holder"
  96. Part.BrickColor = BrickColor.new("Dark stone grey")
  97. Part.TopSurface = 0
  98. Part.BottomSurface = 0
  99. Part.FormFactor = "Custom"
  100. Part.Size = Vector3.new(1, 1, 1)
  101. Part.Parent = Parts
  102. local Mesh = Instance.new("CylinderMesh")
  103. Mesh.Scale = Vector3.new(0.25, 0.4, 0.25)
  104. Mesh.Parent = Part
  105. local Weld = Instance.new("Weld")
  106. Weld.Part0 = Part
  107. Weld.Part1 = MasterPart
  108. Weld.C0 = CFrame.new(0, -0.5, 0)
  109. Weld.Parent = Weld.Part0
  110.  
  111. local MasterPart2 = Instance.new("Part")
  112. MasterPart2.Name = "Pin"
  113. MasterPart2.FormFactor = "Custom"
  114. MasterPart2.Size = Vector3.new(1, 1, 1)
  115. MasterPart2.BrickColor = BrickColor.new("Dark stone grey")
  116. MasterPart2.Transparency = 0
  117. MasterPart2.Locked = true
  118. MasterPart2.TopSurface = 0
  119. MasterPart2.BottomSurface = 0
  120. MasterPart2.Parent = Parts
  121. local Mesh = Instance.new("SpecialMesh")
  122. Mesh.MeshType = "Brick"
  123. Mesh.Scale = Vector3.new(0.1, 0.1, 0.2)
  124. Mesh.Parent = MasterPart2
  125. local Weld = Instance.new("Weld")
  126. Weld.Part0 = MasterPart2
  127. Weld.Part1 = MasterPart
  128. Weld.C0 = CFrame.new(0, -0.6, 0.15)
  129. Weld.Parent = Weld.Part0
  130.  
  131. local Part = Instance.new("Part")
  132. Part.Name = "Pin Ring"
  133. Part.BrickColor = BrickColor.new("Dark stone grey")
  134. Part.TopSurface = 0
  135. Part.BottomSurface = 0
  136. Part.FormFactor = "Custom"
  137. Part.Size = Vector3.new(1, 1, 1)
  138. Part.Parent = Parts
  139. local Mesh = Instance.new("SpecialMesh")
  140. Mesh.MeshType = "Brick"
  141. Mesh.Scale = Vector3.new(0.15, 0.15, 0.15)
  142. Mesh.Parent = Part
  143. local Weld = Instance.new("Weld")
  144. Weld.Part0 = Part
  145. Weld.Part1 = MasterPart2
  146. Weld.C0 = CFrame.new(0, 0, 0.15)
  147. Weld.Parent = Weld.Part0
  148.  
  149. for _, Part in pairs(Parts:GetChildren()) do
  150. Part.Locked = true
  151. Part.CanCollide = false
  152. end
  153. end
  154.  
  155.  
  156. function RemoveParts(Parent, Format)
  157. if Format == 1 then
  158. pcall(function() Parent[ModelName.. " (Holstered)"]:Remove() end)
  159. elseif Format == 2 then
  160. pcall(function() Parent[ModelName]:Remove() end)
  161. end
  162. end
  163.  
  164.  
  165. function SetAngle(Joint, Angle, Character)
  166. if Character == nil then return false end
  167. local Joints = {
  168. Character.Torso:FindFirstChild("Right Shoulder 2"),
  169. Character.Torso:FindFirstChild("Left Shoulder 2"),
  170. Character.Torso:FindFirstChild("Right Hip 2"),
  171. Character.Torso:FindFirstChild("Left Hip 2")
  172. }
  173. if Joints[Joint] == nil then return false end
  174. if Joint == 1 or Joint == 3 then
  175. Joints[Joint].DesiredAngle = Angle
  176. end
  177. if Joint == 2 or Joint == 4 then
  178. Joints[Joint].DesiredAngle = -Angle
  179. end
  180. end
  181.  
  182.  
  183. function ForceAngle(Joint, Angle, Character)
  184. if Character == nil then return false end
  185. local Joints = {
  186. Character.Torso:FindFirstChild("Right Shoulder 2"),
  187. Character.Torso:FindFirstChild("Left Shoulder 2"),
  188. Character.Torso:FindFirstChild("Right Hip 2"),
  189. Character.Torso:FindFirstChild("Left Hip 2")
  190. }
  191. if Joints[Joint] == nil then return false end
  192. if Joint == 1 or Joint == 3 then
  193. Joints[Joint].DesiredAngle = Angle
  194. Joints[Joint].CurrentAngle = Angle
  195. end
  196. if Joint == 2 or Joint == 4 then
  197. Joints[Joint].DesiredAngle = -Angle
  198. Joints[Joint].CurrentAngle = -Angle
  199. end
  200. end
  201.  
  202.  
  203. function SetSpeed(Joint, Speed, Character)
  204. if Character == nil then return false end
  205. local Joints = {
  206. Character.Torso:FindFirstChild("Right Shoulder 2"),
  207. Character.Torso:FindFirstChild("Left Shoulder 2"),
  208. Character.Torso:FindFirstChild("Right Hip 2"),
  209. Character.Torso:FindFirstChild("Left Hip 2")
  210. }
  211. if Joints[Joint] == nil then return false end
  212. Joints[Joint].MaxVelocity = Speed
  213. end
  214.  
  215.  
  216. function DisableLimb(Limb, Character)
  217. if Character == nil then return false end
  218. if Character:FindFirstChild("Torso") == nil then return false end
  219. local Joints = {
  220. Character.Torso:FindFirstChild("Right Shoulder"),
  221. Character.Torso:FindFirstChild("Left Shoulder"),
  222. Character.Torso:FindFirstChild("Right Hip"),
  223. Character.Torso:FindFirstChild("Left Hip")
  224. }
  225. local Limbs = {
  226. Character:FindFirstChild("Right Arm"),
  227. Character:FindFirstChild("Left Arm"),
  228. Character:FindFirstChild("Right Leg"),
  229. Character:FindFirstChild("Left Leg")
  230. }
  231. if Joints[Limb] == nil then return false end
  232. if Limbs[Limb] == nil then return false end
  233. local Joint = Instance.new("Motor6D")
  234. Joint.Parent = Character.Torso
  235. Joint.Part0 = Character.Torso
  236. Joint.Part1 = Limbs[Limb]
  237. if Limb == 1 then
  238. Joint.C0 = CFrame.new(1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  239. Joint.C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  240. Joint.Name = "Right Shoulder 2"
  241. elseif Limb == 2 then
  242. Joint.C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  243. Joint.C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  244. Joint.Name = "Left Shoulder 2"
  245. elseif Limb == 3 then
  246. Joint.C0 = CFrame.new(0.5, -1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  247. Joint.C1 = CFrame.new(0, 1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  248. Joint.Name = "Right Hip 2"
  249. elseif Limb == 4 then
  250. Joint.C0 = CFrame.new(-0.5, -1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  251. Joint.C1 = CFrame.new(0, 1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  252. Joint.Name = "Left Hip 2"
  253. end
  254. Joint.MaxVelocity = Joints[Limb].MaxVelocity
  255. Joint.CurrentAngle = Joints[Limb].CurrentAngle
  256. Joint.DesiredAngle = Joints[Limb].DesiredAngle
  257. Joints[Limb]:Remove()
  258. end
  259.  
  260.  
  261. function ResetLimbCFrame(Limb, Character)
  262. if Character == nil then return false end
  263. if Character.Parent == nil then return false end
  264. if Character:FindFirstChild("Torso") == nil then return false end
  265. local Joints = {
  266. Character.Torso:FindFirstChild("Right Shoulder 2"),
  267. Character.Torso:FindFirstChild("Left Shoulder 2"),
  268. Character.Torso:FindFirstChild("Right Hip 2"),
  269. Character.Torso:FindFirstChild("Left Hip 2")
  270. }
  271. local Limbs = {
  272. Character:FindFirstChild("Right Arm"),
  273. Character:FindFirstChild("Left Arm"),
  274. Character:FindFirstChild("Right Leg"),
  275. Character:FindFirstChild("Left Leg")
  276. }
  277. if Joints[Limb] == nil then return false end
  278. if Limbs[Limb] == nil then return false end
  279. if Limb == 1 then
  280. Joints[Limb].C0 = CFrame.new(1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  281. Joints[Limb].C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  282. elseif Limb == 2 then
  283. Joints[Limb].C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  284. Joints[Limb].C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  285. elseif Limb == 3 then
  286. Joints[Limb].C0 = CFrame.new(0.5, -1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  287. Joints[Limb].C1 = CFrame.new(0, 1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  288. elseif Limb == 4 then
  289. Joints[Limb].C0 = CFrame.new(-0.5, -1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  290. Joints[Limb].C1 = CFrame.new(0, 1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  291. end
  292. end
  293.  
  294.  
  295. function EnableLimb(Limb, Character)
  296. if Character == nil then return false end
  297. if Character:FindFirstChild("Torso") == nil then return false end
  298. local Joints = {
  299. Character.Torso:FindFirstChild("Right Shoulder 2"),
  300. Character.Torso:FindFirstChild("Left Shoulder 2"),
  301. Character.Torso:FindFirstChild("Right Hip 2"),
  302. Character.Torso:FindFirstChild("Left Hip 2")
  303. }
  304. local Limbs = {
  305. Character:FindFirstChild("Right Arm"),
  306. Character:FindFirstChild("Left Arm"),
  307. Character:FindFirstChild("Right Leg"),
  308. Character:FindFirstChild("Left Leg")
  309. }
  310. if Joints[Limb] == nil then return false end
  311. if Limbs[Limb] == nil then return false end
  312. if Limb == 1 then
  313. Joints[Limb].Name = "Right Shoulder"
  314. elseif Limb == 2 then
  315. Joints[Limb].Name = "Left Shoulder"
  316. elseif Limb == 3 then
  317. Joints[Limb].Name = "Right Hip"
  318. elseif Limb == 4 then
  319. Joints[Limb].Name = "Left Hip"
  320. end
  321. Animate = Character:FindFirstChild("Animate")
  322. if Animate == nil then return false end
  323. Animate = Animate:Clone()
  324. Character.Animate:Remove()
  325. Animate.Parent = Character
  326. end
  327.  
  328.  
  329. function onButton1Down(Mouse)
  330. if Button1Down == true then return end
  331. Button1Down = true
  332. if CheckPlayer() == false or Primed == true or Thrown == true or CanUse == false then return end
  333. CanUse = false
  334. Primed = true
  335. --SoundToServer("Pin", "http://www.roblox.com/Asset/?id=2697295", 5, 1, false, Player.Character.Torso)
  336. pcall(function() Player.Character[ModelName].Pin.Weld:Remove() end)
  337. for _, Part in pairs(Player.Character[ModelName]:GetChildren()) do
  338. pcall(function()
  339. if string.match(Part.Name, "Pin") then
  340. Part.CanCollide = true
  341. end
  342. end)
  343. end
  344. tagHumanoid(Player.Character[ModelName].Handle)
  345. Instance.new("Configuration", Player.Character[ModelName].Handle).Name = "CanExplode"
  346. Player.Character[ModelName].Changed:connect(function(Property)
  347. if Property == "Parent" then
  348. while CanUse == false do wait() end
  349. EnableLimb(1, Player.Character)
  350. --UpdateFirstPerson()
  351. script.Parent:Remove()
  352. end
  353. end)
  354. CanUse = true
  355. end
  356.  
  357.  
  358. function onButton1Up(Mouse)
  359. if Button1Down == false then return end
  360. Button1Down = false
  361. if CanUse == false then return end
  362. if Player.Character:FindFirstChild(ModelName) ~= nil and Thrown == false then
  363. Thrown = true
  364. SetSpeed(1, 0.75, Player.Character)
  365. SetAngle(1, 0, Player.Character)
  366. wait()
  367. pcall(function() Player.Character[ModelName].Handle.Weld:Remove() end)
  368. for _, Part in pairs(Player.Character[ModelName]:GetChildren()) do
  369. pcall(function() Part.CanCollide = true end)
  370. end
  371. local BodyVelocity = Instance.new("BodyVelocity")
  372. BodyVelocity.maxForce = Vector3.new(math.huge, math.huge, math.huge)
  373. BodyVelocity.velocity = (Mouse.Hit.p - Player.Character[ModelName].Handle.Position).unit * 75
  374. BodyVelocity.Parent = Player.Character[ModelName].Handle
  375. game:GetService("Debris"):AddItem(BodyVelocity, 0.1)
  376. game:GetService("Debris"):AddItem(Player.Character[ModelName], 10)
  377. Player.Character[ModelName].Parent = Workspace
  378. end
  379. end
  380.  
  381.  
  382. function onKeyDown(Key, Mouse)
  383. if Selected == false then return end
  384. Key = Key:lower()
  385. if Button1Down == false and CanUse == true and CheckPlayer() == true then
  386. if Key == "q" then
  387. if Mouse.Target == nil then return end
  388. if CheckPlayer() == false then return end
  389. local NewPlayer = game:GetService("Players"):GetPlayerFromCharacter(Mouse.Target.Parent)
  390. if NewPlayer == nil then return end
  391. if NewPlayer.Character == nil then return end
  392. if NewPlayer.Character:FindFirstChild("Torso") == nil then return end
  393. if (NewPlayer.Character.Torso.Position - Player.Character.Torso.Position).magnitude > 10 then return end
  394. onDeselected(Mouse)
  395. wait()
  396. RemoveParts(Player.Character, 1)
  397. script.Parent.Parent = NewPlayer.Backpack
  398. Player = NewPlayer
  399. elseif Key == "g" then
  400. CanUse = false
  401. --SoundToServer("Slash", "rbxasset://sounds/swordslash.wav", 2, 1, false, Player.Character.Torso)
  402. SetSpeed(1, 0.75, Player.Character)
  403. SetAngle(1, 0, Player.Character)
  404. local HasHit = false
  405. local _, HitConnection = pcall(function() return Player.Character[ModelName].Handle.Touched:connect(function(Hit)
  406. if HasHit == true or Hit:IsDescendantOf(Player.Character) then return end
  407. HasHit = true
  408. --SoundToServer("Bash", "http://www.roblox.com/Asset/?id=46153268", 1, 0.25, false, Player.Character.Torso)
  409. local Humanoid = Hit.Parent:FindFirstChild("Humanoid") or Hit.Parent.Parent:FindFirstChild("Humanoid")
  410. if Humanoid ~= nil then
  411. tagHumanoid(Humanoid)
  412. Humanoid:TakeDamage(7)
  413. wait()
  414. pcall(function() untagHumanoid(Humanoid) end)
  415. end
  416. end) end)
  417. --CameraSlide(math.rad(-15), 0, 0.2)
  418. pcall(function() HitConnection:disconnect() end)
  419. SetSpeed(1, 0.5, Player.Character)
  420. SetAngle(1, math.rad(200), Player.Character)
  421. --CameraSlide(math.rad(15), 0, 0.25)
  422. CanUse = true
  423. end
  424. end
  425. end
  426.  
  427.  
  428. function onSelected(Mouse)
  429. if Selected == true or CanUse == false then return end
  430. CanUse = false
  431. while true do
  432. if CheckPlayer() == true then
  433. if Player.Character.Torso:FindFirstChild("Right Shoulder") ~= nil then
  434. break
  435. end
  436. end
  437. wait(0.1)
  438. end
  439. Selected = true
  440. RemoveParts(Player.Character, 1)
  441. CreateParts(Player.Character, 2)
  442. DisableLimb(1, Player.Character)
  443. SetSpeed(1, 0.5, Player.Character)
  444. SetAngle(1, math.rad(200), Player.Character)
  445. Mouse.Icon = "rbxasset://textures\\GunCursor.png"
  446. Mouse.Button1Down:connect(function() onButton1Down(Mouse) end)
  447. Mouse.Button1Up:connect(function() onButton1Up(Mouse) end)
  448. Mouse.KeyDown:connect(function(Key) onKeyDown(Key, Mouse) end)
  449. CanUse = true
  450. end
  451.  
  452.  
  453. function onDeselected(Mouse)
  454. if Selected == false or Primed == true then return end
  455. Selected = false
  456. while CanUse == false do wait() end
  457. if Selected == true then return end
  458. CanUse = false
  459. RemoveParts(Player.Character, 2)
  460. CreateParts(Player.Character, 1)
  461. SetAngle(1, 0, Player.Character)
  462. ResetLimbCFrame(1, Player.Character)
  463. EnableLimb(1, Player.Character)
  464. CanUse = true
  465. end
  466.  
  467.  
  468. if script.Parent.ClassName ~= "HopperBin" then
  469. if Player == nil then print("Error: Player not found!") return end
  470. Tool = Instance.new("HopperBin")
  471. Tool.Name = ModelName
  472. Tool.Parent = Player.Backpack
  473. script.Name = "Main"
  474. script.Parent = Tool
  475. elseif script.Parent.ClassName == "HopperBin" and Connected == false then
  476. Connected = true
  477. Player = script.Parent.Parent.Parent
  478. end wait() if script.Parent.ClassName == "HopperBin" then
  479. while script.Parent.Parent.ClassName ~= "Backpack" do
  480. wait()
  481. end
  482. script.Parent.Selected:connect(onSelected)
  483. script.Parent.Deselected:connect(onDeselected)
  484. CreateParts(Player.Character, 1)
  485. end
Add Comment
Please, Sign In to add comment