BOBBIEBOY

Lighting body

Dec 17th, 2016
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.62 KB | None | 0 0
  1. --mediafire
  2. script.Parent = nil
  3. ---(pathdistance / BoltLength))
  4. --c/workspace.ChildAdded:connect(function(child) if child:IsA("Model") then e = Instance.new("Script", child) end end) --mediafire
  5. for _, v in pairs(script:GetChildren()) do
  6. v:Destroy()
  7. end
  8. ypcall(function()
  9. debugColor = BrickColor.new("Really blue")
  10. debug = false
  11. BoltSize = Vector3.new(.1,.1,.1)
  12. BoltColor = BrickColor.new("New Yeller")
  13. BoltTransparency = .5
  14. BoltLength = 10
  15. BoltDefaultLength = 25
  16. xrange = 1
  17. xrange2 = -1
  18. yrange = 1
  19. yrange2 = -1
  20. zrange = 0
  21. frequency = .25
  22. lightning = false
  23. functionkill = false
  24. randomLightningBool = true
  25. zrange2 = 0
  26. boltbreakdistance = 2
  27. killbubble = 20
  28. RainbowMode = false
  29. Character = game.Players.LocalPlayer.Character
  30. Mouse = game.Players.LocalPlayer:GetMouse()
  31. function ToRGB(HSV)
  32. RGB = {
  33. R = 0,
  34. G = 0,
  35. B = 0,
  36. }
  37. Chroma = HSV.Value * HSV.Saturation
  38. Hx = HSV.Hue / 60
  39. x = Chroma * (1 - math.abs((Hx % 2.0) - 1.0))
  40. if Hx < 1.0 then
  41. RGB.R = Chroma
  42. RGB.G = x
  43. elseif Hx < 2.0 then
  44. RGB.R = x
  45. RGB.G = Chroma
  46. elseif Hx < 3.0 then
  47. RGB.G = Chroma
  48. RGB.B = x
  49. elseif Hx < 4.0 then
  50. RGB.G = x
  51. RGB.B = Chroma;
  52. elseif Hx < 5.0 then
  53. RGB.R = x
  54. RGB.B = Chroma
  55. elseif Hx <= 6.0 then
  56. RGB.R = Chroma
  57. RGB.B = x
  58. end
  59. Min = HSV.Value - Chroma
  60. RGB.R = RGB.R + Min
  61. RGB.G = RGB.G + Min
  62. RGB.B = RGB.B + Min
  63. return RGB.R, RGB.G, RGB.B
  64. end
  65. function Debug(t)
  66. local debugModel = Instance.new("Model", workspace)
  67. for _, v in pairs(t) do
  68. local p = Instance.new("Part",debugModel)
  69. p.FormFactor = "Custom"
  70. p.BrickColor = debugColor
  71. p.Size = BoltSize
  72. p.TopSurface = "Smooth"
  73. p.BottomSurface = "Smooth"
  74. p.Anchored = true
  75. p.CFrame = v
  76. local b = Instance.new("BillboardGui", p)
  77. b.Adornee = p
  78. b.StudsOffset = Vector3.new(0, 3, 0)
  79. b.Size = UDim2.new(10,0,10,0)
  80. local x = Instance.new("TextBox", b)
  81. x.Size = UDim2.new(1,0,1,0)
  82. x.Text = _
  83. x.BackgroundTransparency = 1
  84. x.TextColor3 = Color3.new(1,1,1)
  85. x.FontSize = "Size14"
  86. end
  87. end
  88. function DrawPath(origin, target)
  89. local path = {origin}
  90. local lastpoint = origin
  91. local pathdistance = (origin.p - target.p).magnitude
  92. repeat
  93. local breakpoint = nil
  94. local breakend = false
  95. local newpoint = nil
  96. if (lastpoint.p - target.p).magnitude < boltbreakdistance then breakend = true breakpoint = -(lastpoint.p - target.p).magnitude else breakpoint = -2 end
  97. if not breakend then
  98. newpoint = CFrame.new(lastpoint.p, target.p) * CFrame.new(math.random(xrange2, xrange), math.random(yrange2, yrange), breakpoint)
  99. else
  100. newpoint = CFrame.new(lastpoint.p, target.p) * CFrame.new(0,0, breakpoint)
  101. end
  102. table.insert(path, #path + 1, newpoint)
  103. lastpoint = newpoint
  104. local distance = (lastpoint.p - target.p).magnitude
  105. until distance <= 0 or #path > 150
  106. table.insert(path, #path + 1, target)
  107. return path
  108. end
  109. function CheckIfPlayer(obj)
  110. checkplayer = game.Players:FindFirstChild(obj.Parent.Name)
  111. if checkplayer then
  112. return checkplayer
  113. else
  114. return nil
  115. end
  116. end
  117. function CreateBolt(target, origin, waittime)
  118. if waittime then wait(waittime) end
  119. local randomnumber = math.random(1,10)
  120. local boltModel = Instance.new("Model", workspace)
  121. local boltPath = nil
  122. if not waittime then
  123. boltPath = DrawPath(origin.CFrame, target.Character.Torso.CFrame)
  124. else
  125. boltPath = DrawPath(origin.CFrame, target)
  126. end
  127. if debug == true then Debug(boltPath) end
  128. for i = 1, #boltPath do
  129. if i == #boltPath then break end
  130. local p = Instance.new("Part", boltModel)
  131. p.FormFactor = "Custom"
  132. if RainbowMode then
  133. local HSV = {
  134. Hue = 360/(i * randomnumber/10),
  135. Saturation = 1,
  136. Value = 1
  137. }
  138. local R, G, B = ToRGB(HSV)
  139. p.BrickColor = BrickColor.new(R, G, B)
  140. else
  141. p.BrickColor = BoltColor
  142. end
  143. p.Transparency = BoltTransparency
  144. p.Size = BoltSize
  145. p.TopSurface = "Smooth"
  146. p.BottomSurface = "Smooth"
  147. p.Anchored = true
  148. p.CanCollide = false
  149. p.Size = Vector3.new(BoltSize.X, BoltSize.Y, (boltPath[i].p - boltPath[i + 1].p).magnitude)
  150. p.CFrame = CFrame.new(boltPath[i + 1].p, boltPath[i].p) * CFrame.new(0,0,-((boltPath[i].p - boltPath[i + 1].p).magnitude / 2))
  151. end
  152. if not waittime then
  153. local distance = (boltPath[1].p - boltPath[#boltPath].p).magnitude
  154. local damagemodifer = (distance / killbubble) * 75
  155. if target.Character:FindFirstChild("Humanoid") then
  156. if target.Character.Humanoid.Health ~= math.huge and target.Character.Humanoid.MaxHealth ~= math.huge then
  157. local damage = (target.Character.Humanoid.MaxHealth/damagemodifer)
  158. target.Character.Humanoid.Health = target.Character.Humanoid.Health - damage
  159. killbubble = killbubble + (damage/target.Character.Humanoid.MaxHealth) / 25
  160. end
  161. end
  162. end
  163. for i=BoltTransparency, 1, .02 do
  164. wait()
  165. for _, v in pairs(boltModel:GetChildren()) do
  166. v.Transparency = i
  167. end
  168. end
  169. boltModel:Destroy()
  170. end
  171. Mouse.KeyDown:connect(function(key)
  172. if key == "0" then
  173. functionkill = true
  174. end
  175. if key == "r" then
  176. if RainbowMode == false then RainbowMode = true return end
  177. if RainbowMode == true then RainbowMode = false return end
  178. end
  179. end)
  180.  
  181. while wait(frequency) do
  182. if functionkill then break end
  183. local noplayer = false
  184. if game.Players.LocalPlayer.Character:FindFirstChild("Head") then
  185. for _, v in pairs(game.Players:GetChildren()) do
  186. if v.Character then
  187. if v ~= game.Players.LocalPlayer then
  188. if v.Character:FindFirstChild("Humanoid") then
  189. if v.Character.Humanoid.Health > 0 then
  190. if v.Character:FindFirstChild("Torso") then
  191. if(v.Character.Torso.CFrame.p - game.Players.LocalPlayer.Character.Head.CFrame.p).magnitude < killbubble then
  192. if noplayer == false then noplayer = true end
  193. coroutine.resume(coroutine.create(CreateBolt), v, game.Players.LocalPlayer.Character.Head, false)
  194. end
  195. end
  196. end
  197. end
  198. end
  199. end
  200. end
  201. if randomLightningBool == true and noplayer == false then
  202. local mathvar1 = math.random(1,2)
  203. local mathvar2 = math.random(1,2)
  204. local mathvar3 = math.random(1,2)
  205. if mathvar1 == 2 then mathvar1 = killbubble * math.random(-1, 1) end
  206. if mathvar2 == 2 then mathvar2 = killbubble * math.random(-1, 1) end
  207. if mathvar3 == 2 then mathvar3 = killbubble * math.random(-1, 1) end
  208. local x = killbubble * math.sin(mathvar1) * math.random(-1, 1)
  209. local y = killbubble * math.sin(mathvar2) * math.random(-1, 1)
  210. local z = killbubble * math.cos(mathvar3) * math.random(-1, 1)
  211. coroutine.resume(coroutine.create(CreateBolt), game.Players.LocalPlayer.Character.Head.CFrame * CFrame.new(x,y,z), game.Players.LocalPlayer.Character.Head, 1/30)
  212. end
  213. end
  214. end
  215. end)
  216. --poor powerful notice goal third finish metal husband serve odd flame cease
Add Comment
Please, Sign In to add comment