Advertisement
Er1x_Official

Lightning Bolt Roblox

Sep 11th, 2021
376
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.32 KB | None | 0 0
  1. local debree = game:GetService("Debris")
  2. local tweens = game:GetService("TweenService")
  3.  
  4. local function AddDmg(Part, Damage)
  5.     local canddmg = true
  6.     Part.Touched:Connect(function(hit)
  7.         local hum = hit.Parent:FindFirstChildOfClass("Humanoid")
  8.         if canddmg then
  9.             if hum == nil then
  10.                 hum = hit.Parent.Parent:FindFirstChildOfClass("Humanoid")
  11.                 if hum then
  12.                     canddmg = false;hum:TakeDamage(Damage)
  13.                 end
  14.             else
  15.                 canddmg = false;hum:TakeDamage(Damage)
  16.             end
  17.         end
  18.     end)
  19. end
  20.  
  21. local function boltEffect(Start, Finish, Length, Spread, Time, Bolts, Pillar, DelayAnim, Aoe)
  22.     local points = {}
  23.     local tinfo = TweenInfo.new(Time)
  24.     local p = Instance.new("Part")
  25.     p.Anchored = true
  26.     p.CanCollide = false
  27.     p.CastShadow = false
  28.     p.Locked = true
  29.     p.Massless = true
  30.     p.Transparency = math.random(-0.1,0.8)
  31.     p.BrickColor = BrickColor.new("Medium blue")
  32.     p.Material = Enum.Material.Neon
  33.     p.Size = Vector3.new(1,1,1)
  34.  
  35.     for i = 0, Length do
  36.         local j = math.random(1,Spread) -- spread
  37.         local offset = Vector3.new(math.random(-j,j),math.random(-j,j),math.random(-j,j))
  38.         local position = Start + (Finish - Start).Unit*i*(Finish - Start).Magnitude/Length
  39.         local folder = workspace:FindFirstChild("Debree")
  40.  
  41.         if i == 0 or i == Length then
  42.             offset = Vector3.new(0,0,0)
  43.  
  44.             if folder == nil then
  45.                 Instance.new("Folder",workspace).Name = "Debree"
  46.                 folder = workspace:FindFirstChild("Debree")
  47.             end
  48.  
  49.             if i == Length then
  50.                 local pe = p:Clone()
  51.                 pe.Shape = Enum.PartType.Ball
  52.                 pe.Position = Finish
  53.                 pe.Parent = folder
  54.                 pe.Name = "Ball"
  55.  
  56.                 local g = {}
  57.                 g.Size = Vector3.new(15,15,15)
  58.                 g.Transparency = 1
  59.                 g.Color = Color3.fromHSV(0.5, 0.5, 1)
  60.                 tweens:Create(pe,TweenInfo.new(Time),g):Play()
  61.             end
  62.         end
  63.  
  64.         points[#points + 1] = position + offset    
  65.     end
  66.  
  67.     spawn(function()
  68.         if Pillar == true then
  69.             local bolt = {}
  70.             for i = 0, Length do
  71.                 local position = Start + (Finish - Start).Unit*i*(Finish - Start).Magnitude/Length
  72.                 bolt[#bolt + 1] = position 
  73.             end
  74.  
  75.             for i = 1, #bolt do
  76.                 if bolt[i + 1] ~= nil then                     
  77.                     local color = BrickColor.new()
  78.                     local m = math.random(1,2)
  79.                     local folder = workspace:FindFirstChild("Debree")
  80.  
  81.                     if folder == nil then
  82.                         Instance.new("Folder",workspace).Name = "Debree"
  83.                         folder = workspace:FindFirstChild("Debree")
  84.                     end
  85.  
  86.                     if m == 1 then
  87.                         color = BrickColor.new("Pastel Blue")
  88.                     else
  89.                         color = BrickColor.new("Medium blue")
  90.                     end
  91.  
  92.                     local pa = p:Clone()
  93.                     pa.Size = Vector3.new(0.5,0.5, (bolt[i] - bolt[i + 1]).Magnitude)
  94.                     pa.CFrame = CFrame.new((bolt[i] + bolt[i + 1])/2, bolt[i + 1])
  95.                     pa.BrickColor = color
  96.                     pa.Name = "Pillar"
  97.                     pa.Parent = folder
  98.  
  99.                     local g = {}
  100.                     g.Size = Vector3.new(1,1,pa.Size.Z)
  101.                     g.Transparency = 1
  102.  
  103.                     tweens:Create(pa,TweenInfo.new(Time*1.1),g):Play()
  104.                     debree:AddItem(pa,Time*1.1)
  105.                 end
  106.             end
  107.         end
  108.  
  109.         for i = 1, #points do
  110.             if points[i + 1] ~= nil then
  111.                 if DelayAnim == true then
  112.                     wait()
  113.                 end
  114.  
  115.                 if Bolts <= 0 or Bolts == nil then
  116.                     Bolts = 1
  117.                 end
  118.  
  119.                 for s = 1, Bolts do
  120.                     local color = BrickColor.new()
  121.                     local m = math.random(1,2)
  122.                     local folder = workspace:FindFirstChild("Debree")
  123.  
  124.                     if folder == nil then
  125.                         Instance.new("Folder",workspace).Name = "Debree"
  126.                         folder = workspace:FindFirstChild("Debree")
  127.                     end
  128.  
  129.                     if m == 1 then
  130.                         color = BrickColor.new("Pastel Blue")
  131.                     else
  132.                         color = BrickColor.new("Medium blue")
  133.                     end
  134.  
  135.                     local pa = p:Clone()
  136.                     pa.Size = Vector3.new(1,1, (points[i] - points[i + 1]).Magnitude)
  137.                     pa.CFrame = CFrame.new((points[i] + points[i + 1])/2, points[i + 1])
  138.                     pa.BrickColor = color
  139.                     pa.Name = "Bolts"
  140.                     pa.Parent = folder
  141.  
  142.                     if Aoe == true then
  143.                         AddDmg(pa,10)
  144.                     end            
  145.  
  146.                     local g = {}
  147.                     g.Size = Vector3.new(1.5,1.5,pa.Size.Z)
  148.                     g.Transparency = 1
  149.  
  150.                     tweens:Create(pa,tinfo,g):Play()
  151.                     debree:AddItem(pa,Time)
  152.                 end
  153.             end
  154.         end
  155.     end)
  156. end
  157.  
  158. spawn(function()
  159.     while wait(1) do
  160.         boltEffect(workspace.start.Position,workspace.finish.Position,math.random(5,25),math.random(3,8),1,1,true,false,true)
  161.     end
  162. end) -- thats it (this is client sided, it might work with normal scripts, i havent tested it yet tho)
  163.  
  164. -- made by eric/Er_1x/ERIC#2073
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement