Advertisement
CloneTrooper1019

BrightExplosions.lua

Oct 4th, 2018
819
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.26 KB | None | 0 0
  1. local RunService = game:GetService("RunService")
  2. local TweenService = game:GetService("TweenService")
  3. local RNG = Random.new()
  4.  
  5. local node = Instance.new("Part")
  6. node.Name = "_ExplosionLightNode"
  7. node.Anchored = true
  8. node.CanCollide = false
  9. node.Locked = true
  10. node.Transparency = 1
  11. node.Parent = workspace
  12.  
  13. local expFadeOut = { Brightness = 0, Range = 0, Color = Color3.new() }
  14. local expTweenOut = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.In)
  15. local expTweenIn = TweenInfo.new(0.5, Enum.EasingStyle.Back, Enum.EasingDirection.Out)
  16.  
  17. local function onExplosion(exp)
  18.     local att = Instance.new("Attachment")
  19.     att.Name = exp:GetFullName()
  20.     att.CFrame = CFrame.new(exp.Position)
  21.    
  22.     local innerLight = Instance.new("PointLight")
  23.     innerLight.Name = "InnerLight"
  24.     innerLight.Brightness = expFadeOut.Brightness
  25.     innerLight.Range = expFadeOut.Range
  26.     innerLight.Color = expFadeOut.Color
  27.     innerLight.Shadows = true
  28.    
  29.     local outerLight = innerLight:Clone()
  30.     outerLight.Name = "OuterLight"
  31.    
  32.     local innerFadeIn =
  33.     {
  34.         Brightness = exp.BlastRadius * 30;
  35.         Range = exp.BlastRadius * 1.5;
  36.         Color = Color3.new(1,0.5,0.25);
  37.     }
  38.    
  39.     local outerFadeIn =
  40.     {
  41.         Brightness = exp.BlastRadius * 2;
  42.         Range = exp.BlastRadius * 3;
  43.         Color = Color3.new(1,0.5,0.25);
  44.     }
  45.  
  46.     innerLight.Parent = att
  47.     outerLight.Parent = att
  48.     att.Parent = node
  49.    
  50.     spawn(function ()
  51.         while exp:IsDescendantOf(workspace) do
  52.             local x = RNG:NextNumber(-1,1)
  53.             local y = RNG:NextNumber(-1,1)
  54.             local z = RNG:NextNumber(-1,1)
  55.            
  56.             att.CFrame = CFrame.new(exp.Position) * CFrame.new(x,y,z)
  57.             RunService.Heartbeat:Wait()
  58.         end
  59.     end)
  60.    
  61.     local innerTweenIn = TweenService:Create(innerLight, expTweenIn, innerFadeIn)
  62.     local outerTweenIn = TweenService:Create(outerLight, expTweenIn, outerFadeIn)
  63.     innerTweenIn:Play()
  64.     outerTweenIn:Play()
  65.  
  66.     wait(expTweenIn.Time)
  67.  
  68.     local innerTweenOut = TweenService:Create(innerLight, expTweenOut, expFadeOut)
  69.     local outerTweenOut = TweenService:Create(outerLight, expTweenOut, expFadeOut)
  70.    
  71.     innerTweenOut:Play()
  72.     outerTweenOut:Play()
  73.    
  74.     wait(expTweenOut.Time)
  75.     att:Destroy()
  76. end
  77.  
  78. local function onDescendantAdded(desc)
  79.     if desc:IsA("Explosion") then
  80.         onExplosion(desc)
  81.     end
  82. end
  83.  
  84. workspace.DescendantAdded:Connect(onDescendantAdded)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement