Advertisement
HenloMyDude

jjkshield

Aug 25th, 2019
902
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.25 KB | None | 0 0
  1.  
  2. script.Name = "Shield"
  3. wait(0.25)
  4. if owner == nil then script:Destroy() return end
  5. local PartB = Instance.new("Part")
  6. local SB = Instance.new("Sound",PartB)
  7. SB.SoundId = "rbxasset://sounds/impact_explosion_03.mp3"
  8. SB.Volume = 1.4
  9. SB.PlayOnRemove = true
  10. local PartC = Instance.new("Part")
  11. local SC = Instance.new("Sound",PartC)
  12. SC.SoundId = "rbxasset://sounds/collide.wav"
  13. SC.Volume = 1.4
  14. SC.PlayOnRemove = true
  15. local PartD = Instance.new("Part")
  16. local SD = Instance.new("Sound",PartD)
  17. SD.SoundId = "rbxasset://sounds/Rocket shot.wav"
  18. SD.Volume = 1.4
  19. SD.PlayOnRemove = true
  20. PartB.Anchored = true
  21. PartC.Anchored = true
  22. PartD.Anchored = true
  23. function HitSound(pos)
  24. local random = math.random(1,3)
  25. if random == 1 then
  26. if SB and SB.Parent then
  27. SB.PlaybackSpeed = math.random(240,360) / 100
  28. end
  29. if PartB then
  30. PartB.Position = pos
  31. PartB.Parent = script
  32. PartB.Parent = nil
  33. end
  34. elseif random == 2 then
  35. if SC then
  36. SC.PlaybackSpeed = math.random(140,360) / 100
  37. end
  38. if PartC then
  39. PartC.Position = pos
  40. PartC.Parent = script
  41. PartC.Parent = nil
  42. end
  43. elseif random == 3 then
  44. if SD then
  45. SD.PlaybackSpeed = math.random(1600,2000) / 100
  46. end
  47. if PartD then
  48. PartD.Position = pos
  49. PartD.Parent = script
  50. PartD.Parent = nil
  51. end
  52. end
  53. end
  54. function Kaboom(pos)
  55. local random = math.random(1,3)
  56. if random == 1 then
  57. if SB and SB.Parent then
  58. SB.PlaybackSpeed = math.random(80,160) / 100
  59. end
  60. if PartB then
  61. PartB.Position = pos
  62. PartB.Parent = script
  63. PartB.Parent = nil
  64. end
  65. elseif random == 2 then
  66. if SC then
  67. SC.PlaybackSpeed = math.random(60,120) / 100
  68. end
  69. if PartC then
  70. PartC.Position = pos
  71. PartC.Parent = script
  72. PartC.Parent = nil
  73. end
  74. elseif random == 3 then
  75. if SD then
  76. SD.PlaybackSpeed = math.random(120,240) / 100
  77. end
  78. if PartD then
  79. PartD.Position = pos
  80. PartD.Parent = script
  81. PartD.Parent = nil
  82. end
  83. end
  84. end
  85. function NearNumber(a,b)
  86. if a + 0.375 >= b and a - 0.375 <= b then
  87. return true
  88. else
  89. return false
  90. end
  91. end
  92. function Hit(hit,p,o,d,s,t)
  93. if hit and hit.Parent then
  94. local Humanoid = hit.Parent:FindFirstChildWhichIsA("Humanoid")
  95. if Humanoid then
  96. if p then
  97. p:Emit(100)
  98. end
  99. Humanoid:TakeDamage(12)
  100. local creator = Instance.new("ObjectValue",Humanoid)
  101. creator.Name = "creator"
  102. if o and o.Parent then
  103. creator.Value = o
  104. end
  105. game:GetService("Debris"):AddItem(creator,0.2)
  106. if s then
  107. Humanoid:TakeDamage(588)
  108. if d then
  109. d.PlaybackSpeed = 1.175
  110. d:Play()
  111. end
  112. end
  113. delay(0,function()
  114. HitSound(hit.Position)
  115. end)
  116. elseif Humanoid == nil and (hit:GetMass() < 120 or (s and hit:GetMass() < 2400)) then
  117. if p then
  118. p:Emit(100)
  119. end
  120. hit:BreakJoints()
  121. delay(0,function()
  122. HitSound(hit.Position)
  123. end)
  124. end
  125. local Tag2 = hit.Parent:FindFirstChild("FakeHumanoid")
  126. if Tag2 and o and o.Parent then
  127. Tag2.Value = o.Name
  128. end
  129. if s == true then
  130. if p then
  131. p:Emit(100)
  132. end
  133. delay(0,function()
  134. HitSound(hit.Position)
  135. end)
  136. local Direction = (hit.Position - t.Position).unit
  137. local BodyForce = Instance.new("BodyForce",hit)
  138. BodyForce.Force = Direction * 160000
  139. game:GetService("Debris"):AddItem(BodyForce,0.2)
  140. if math.random(1,32) == 1 then
  141. hit:BreakJoints()
  142. p:Emit(320)
  143. Kaboom(hit.Position)
  144. end
  145. end
  146. end
  147. end
  148. function Ready()
  149. local Tool = Instance.new("Tool",owner.Backpack)
  150. Tool.Name = "Shield"
  151. Tool.TextureId = "rbxasset://textures/blackBkg_round.png"
  152. Tool.GripPos = Vector3.new(1,0.5,0.5)
  153. local Torso = Instance.new("Part",Tool)
  154. Torso.Name = "Handle"
  155. Torso.Size = Vector3.new(4,4,1)
  156. Torso.BrickColor = BrickColor.new("Medium stone grey")
  157. Torso.Material = Enum.Material.Metal
  158. Torso.Locked = true
  159. Torso.CustomPhysicalProperties = PhysicalProperties.new(Enum.Material.Metal)
  160. local SoundA = Instance.new("Sound",Torso)
  161. SoundA.SoundId = "rbxasset://sounds/swordslash.wav"
  162. SoundA.Volume = 1.2
  163. local SoundB = Instance.new("Sound",Torso)
  164. SoundB.SoundId = "rbxasset://sounds/Shoulder fired rocket.wav"
  165. SoundB.Volume = 1.2
  166. local SoundC = Instance.new("Sound",Torso)
  167. SoundC.SoundId = "rbxasset://sounds/flashbulb.wav"
  168. SoundC.Volume = 1.2
  169. local SoundD = Instance.new("Sound",Torso)
  170. SoundD.SoundId = "rbxasset://sounds/Kid saying Ouch.wav"
  171. SoundD.Volume = 1.2
  172. local A = Instance.new("Attachment",Torso)
  173. local Particles = Instance.new("ParticleEmitter",A)
  174. Particles.LightEmission = 1
  175. Particles.LightInfluence = 0.2
  176. Particles.Drag = 16
  177. Particles.Enabled = false
  178. Particles.Lifetime = NumberRange.new(0.1,0.4)
  179. Particles.Rate = 100
  180. Particles.Rotation = NumberRange.new(-360,360)
  181. Particles.SpreadAngle = Vector2.new(-360,360)
  182. Particles.Transparency = NumberSequence.new({NumberSequenceKeypoint.new(0,0),NumberSequenceKeypoint.new(0.8,0),NumberSequenceKeypoint.new(1,1)})
  183. Particles.Texture = "rbxasset://textures/particles/sparkles_main.dds"
  184. Particles.Speed = NumberRange.new(70,70)
  185. Particles.Size = NumberSequence.new(0.7,0.7)
  186. local BA0 = Instance.new("Attachment",Torso)
  187. BA0.Position = Vector3.new(-2,0,0.5)
  188. local BA1 = Instance.new("Attachment",Torso)
  189. BA1.Position = Vector3.new(2,0,0.5)
  190. local ShipTrail = Instance.new("Trail",script)
  191. ShipTrail.Color = ColorSequence.new(Torso.Color)
  192. ShipTrail.Transparency = NumberSequence.new(0,1)
  193. ShipTrail.MinLength = 0.02
  194. ShipTrail.Lifetime = 0.3
  195. ShipTrail.FaceCamera = true
  196. ShipTrail.Attachment0 = BA0
  197. ShipTrail.Attachment1 = BA1
  198. local Beam = Instance.new("Beam",script)
  199. Beam.Attachment0 = A
  200. Beam.FaceCamera = true
  201. local Bill = Instance.new("BillboardGui",script)
  202. Bill.Size = UDim2.new(16,0,16,0)
  203. local Image = Instance.new("ImageLabel",Bill)
  204. Image.Image = "rbxasset://textures/sparkle.png"
  205. Image.Size = UDim2.new(1,0,1,0)
  206. Image.Position = UDim2.new(0.5,0,0.5,0)
  207. Image.AnchorPoint = Vector2.new(0.5,0.5)
  208. Image.ImageTransparency = 1
  209. Image.BackgroundTransparency = 1
  210. Fire = 0
  211. local Resistance = 200
  212. local Connection
  213. local CurrentHumanoid
  214. local CurrentHealth
  215. local LastSuper = false
  216. local function HealthChanged(NewHealth)
  217. if CurrentHumanoid ~= nil then
  218. if CurrentHumanoid.Health < CurrentHealth then
  219. Resistance = Resistance - math.min(CurrentHealth - CurrentHumanoid.Health,60)
  220. CurrentHumanoid.Health = CurrentHealth
  221. if Torso then
  222. HitSound(Torso.Position)
  223. Bill.StudsOffsetWorldSpace = Torso.Position
  224. Image.ImageColor3 = Torso.Color
  225. Image.ImageTransparency = 0
  226. end
  227. if Resistance <= 0 then
  228. local Player = game:GetService("Players"):GetPlayerFromCharacter(CurrentHumanoid.Parent)
  229. if Player then
  230. Tool.Parent = Player:FindFirstChildWhichIsA("Backpack")
  231. else
  232. Tool.Parent = nil
  233. end
  234. end
  235. end
  236. if CurrentHumanoid ~= nil then
  237. CurrentHealth = CurrentHumanoid.Health
  238. end
  239. end
  240. end
  241. local function Equipped()
  242. Resistance = math.max(80,Resistance)
  243. Fire = math.max(-55,math.min(0,Fire))
  244. Tool.Enabled = true
  245. local Humanoid = Tool.Parent:FindFirstChildWhichIsA("Humanoid")
  246. if Humanoid then
  247. CurrentHumanoid = Humanoid
  248. CurrentHealth = Humanoid.Health
  249. Connection = Humanoid.HealthChanged:Connect(HealthChanged)
  250. end
  251. end
  252. local function Unequipped()
  253. local a = Connection
  254. local b = CurrentHumanoid
  255. if a then
  256. a:Disconnect()
  257. end
  258. if CurrentHumanoid then
  259. CurrentHumanoid = nil
  260. end
  261. local ch = b.Health
  262. local Connect = b.HealthChanged:Connect(function(NewHealth)
  263. if b.Health < ch then
  264. if Torso then
  265. HitSound(Torso.Position)
  266. Bill.StudsOffsetWorldSpace = Torso.Position
  267. Image.ImageColor3 = Torso.Color
  268. Image.ImageTransparency = 0
  269. end
  270. b.Health = ch
  271. end
  272. ch = b.Health
  273. end)
  274. delay(0.8,function()
  275. Connect:Disconnect()
  276. end)
  277. end
  278. Tool.Equipped:Connect(Equipped)
  279. Tool.Unequipped:Connect(Unequipped)
  280. local function Touched(hit)
  281. local Player = game:GetService("Players"):GetPlayerFromCharacter(Tool.Parent)
  282. local Humanoid = Tool.Parent:FindFirstChildWhichIsA("Humanoid")
  283. if Humanoid and Humanoid:GetState() ~= Enum.HumanoidStateType.Dead and Fire > 0 then
  284. Hit(hit,Particles,Player,SoundD,LastSuper,Torso)
  285. if SoundC then
  286. SoundC.PlaybackSpeed = 1.6
  287. SoundC:Play()
  288. end
  289. if Particles then
  290. Particles.Color = ColorSequence.new(Torso.Color)
  291. Particles:Emit(16)
  292. end
  293. end
  294. end
  295. Torso.Touched:Connect(Touched)
  296. local function ValueChange()
  297. if Tool.Enabled == false then
  298. if Torso and Fire <= 0 then
  299. local Player = game:GetService("Players"):GetPlayerFromCharacter(Tool.Parent)
  300. local Character = Tool.Parent
  301. local Humanoid
  302. if Character then
  303. Humanoid = Tool.Parent:FindFirstChildWhichIsA("Humanoid")
  304. end
  305. if Humanoid and Humanoid:GetState() ~= Enum.HumanoidStateType.Dead then
  306. local Super = (Fire <= -75)
  307. local LaunchDirection = Vector3.new(0,0,0)
  308. local Launch = false
  309. if Humanoid.MoveDirection.X ~= 0 or Humanoid.MoveDirection.Z ~= 0 then
  310. LaunchDirection = Torso.CFrame.lookVector
  311. Launch = true
  312. end
  313. if Humanoid:GetState() ~= Enum.HumanoidStateType.Running and Humanoid:GetState() ~= Enum.HumanoidStateType.RunningNoPhysics then
  314. LaunchDirection = LaunchDirection + Vector3.new(0,2,0)
  315. if Launch == true then
  316. LaunchDirection = LaunchDirection + Vector3.new(0,-1,0)
  317. end
  318. Launch = true
  319. end
  320. LastSuper = false
  321. if Super == true then
  322. LastSuper = true
  323. end
  324. if Super and Launch then
  325. local toolanim = Instance.new("StringValue",Tool)
  326. toolanim.Name = "toolanim"
  327. toolanim.Value = "Lunge"
  328. else
  329. local toolanim = Instance.new("StringValue",Tool)
  330. toolanim.Name = "toolanim"
  331. toolanim.Value = "Slash"
  332. end
  333. if Super == true and Launch == true then
  334. SoundB.PlaybackSpeed = 1.75
  335. SoundB:Play()
  336. if Humanoid.SeatPart == nil then
  337. Humanoid.PlatformStand = false
  338. Humanoid.Sit = false
  339. Humanoid.Jump = true
  340. elseif LaunchDirection.Y > 0 then
  341. LaunchDirection = Vector3.new(LaunchDirection.X,LaunchDirection.Y * 0.2,LaunchDirection.Z)
  342. end
  343. local BodyVelocity = Instance.new("BodyVelocity",Torso)
  344. BodyVelocity.MaxForce = Vector3.new(1000000,100000,1000000)
  345. BodyVelocity.Velocity = LaunchDirection * 120
  346. game:GetService("Debris"):AddItem(BodyVelocity,0.6)
  347. end
  348. if SoundA then
  349. SoundA.PlaybackSpeed = 1.4
  350. SoundA:Play()
  351. end
  352. Fire = 12
  353. if Super == true then
  354. Fire = 16
  355. end
  356. end
  357. end
  358. end
  359. end
  360. Tool:GetPropertyChangedSignal("Enabled"):Connect(ValueChange)
  361. local function Activated()
  362. Tool.Enabled = false
  363. end
  364. Tool.Activated:Connect(Activated)
  365. while Tool and Tool:FindFirstAncestorWhichIsA("DataModel") do
  366. Image.ImageTransparency = Image.ImageTransparency + 0.1
  367. Torso.CanCollide = true
  368. Resistance = math.min(200,Resistance + 0.125)
  369. Fire = Fire - 1
  370. if Fire == 0 then
  371. Tool.Enabled = true
  372. end
  373. if Torso and Fire <= -75 then
  374. Torso.Material = Enum.Material.Neon
  375. elseif Torso then
  376. Torso.Material = Enum.Material.Metal
  377. end
  378. Tool.ToolTip = "R = "..math.ceil(Resistance)
  379. if Torso then
  380. if Resistance > 160 then
  381. Torso.BrickColor = BrickColor.new("Toothpaste")
  382. if ShipTrail then
  383. ShipTrail.Color = ColorSequence.new(Color3.new(0,1,1))
  384. end
  385. elseif Resistance > 120 then
  386. Torso.BrickColor = BrickColor.new("Lime green")
  387. if ShipTrail then
  388. ShipTrail.Color = ColorSequence.new(Color3.new(0,1,0))
  389. end
  390. elseif Resistance > 80 then
  391. Torso.BrickColor = BrickColor.new("New Yeller")
  392. if ShipTrail then
  393. ShipTrail.Color = ColorSequence.new(Color3.new(1,1,0))
  394. end
  395. elseif Resistance > 40 then
  396. Torso.BrickColor = BrickColor.new("Hot pink")
  397. if ShipTrail then
  398. ShipTrail.Color = ColorSequence.new(Color3.new(1,0,1))
  399. end
  400. else
  401. Torso.BrickColor = BrickColor.new("Really red")
  402. if ShipTrail then
  403. ShipTrail.Color = ColorSequence.new(Color3.new(1,0,0))
  404. end
  405. end
  406. end
  407. if owner and owner.Parent and owner.Neutral == false then
  408. local TeamColor = owner.TeamColor
  409. Torso.BrickColor = TeamColor
  410. end
  411. wait(0.04)
  412. end
  413. end
  414. Ready()
  415. game:GetService("Debris"):AddItem(script)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement