Advertisement
DanielSiqueira

Light Rain Module Script

Apr 19th, 2020
484
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.33 KB | None | 0 0
  1. local module = {}
  2. module.__index = module
  3.  
  4. local Events = game:GetService('ReplicatedStorage'):WaitForChild('Events')
  5. local RunService = game:GetService('RunService')
  6.  
  7. local TweenService = game:GetService('TweenService')
  8. local Debris = game:GetService('Debris')
  9.  
  10. local Info = {}
  11. local Explosion = script:WaitForChild('Explosion')
  12. local Beam = script:WaitForChild('CenteredBeam')
  13. local Beam2 = script:WaitForChild('Target')
  14.  
  15. local CameraShakeModule = script.Parent.Parent.Parent:WaitForChild('CameraShaker')
  16. local CameraShaker = require(CameraShakeModule)
  17. local ShakePreset = require(CameraShakeModule.CameraShakePresets).Earthquake
  18.  
  19. module.Enabled = true
  20.  
  21. local function renderSkill(player,info)
  22.        
  23.     if RunService:IsServer() then
  24.         local char = player.Character
  25.         local cf = char.HumanoidRootPart.CFrame
  26.         local light = char.HumanoidRootPart:FindFirstChild('LightForm')
  27.         local beam1 = Beam:Clone()
  28.         local beam2 = Beam2:Clone()
  29.         beam1.Beam.Attachment0 = beam1.Attachment
  30.         beam1.Beam.Attachment1 = beam2.Attachment
  31.         if light then
  32.             for i,particle in pairs(light:GetDescendants()) do
  33.                 if particle:IsA('ParticleEmitter') then
  34.                     particle.Enabled = true
  35.                 end
  36.             end
  37.             wait(0.3)
  38.             local Anchored = {}
  39.             for i,part in pairs(char:GetDescendants()) do
  40.                 if part:IsA('BasePart') and part ~= light then
  41.                     if part.Anchored then Anchored[part] = true
  42.                     else
  43.                         part.Anchored = true
  44.                         part.Transparency = 1
  45.                     end
  46.                 end
  47.             end
  48.             local Effect = TweenService:Create(char.HumanoidRootPart,Info.FlyEffect,{CFrame=cf+Vector3.new(0,40,0)})
  49.             Effect:Play()
  50.             wait(1)
  51.             beam1.Parent = workspace
  52.             beam2.Parent = workspace
  53.             beam1.CFrame = char.HumanoidRootPart.CFrame
  54.             beam2.CFrame = cf
  55.             spawn(function()
  56.                 for i = 1,30 do
  57.                     local hit = Events.RequireInputListen:InvokeClient(player,'Mouse.Hit')
  58.                     beam2.CFrame = hit
  59.                     local explosion = Explosion:Clone()
  60.                     explosion.CFrame = hit+Vector3.new(0,1,0)
  61.                     explosion.Parent = workspace
  62.            
  63.                     Debris:AddItem(explosion,0.7)
  64.                     wait(0.125)
  65.                 end
  66.                 Debris:AddItem(beam1,0)
  67.                 Debris:AddItem(beam2,0)
  68.             end)
  69.             wait(5)
  70.             local Effect = TweenService:Create(char.HumanoidRootPart,Info.FlyEffect,{CFrame=cf})
  71.             Effect:Play()
  72.             Effect.Completed:Wait()
  73.             for i,part in pairs(char:GetDescendants()) do
  74.                 if part:IsA('BasePart') then
  75.                     if not Anchored[part] then
  76.                         part.Anchored = false
  77.                         part.Transparency = 0
  78.                     end
  79.                 end
  80.             end
  81.             for i,particle in pairs(light:GetDescendants()) do
  82.                 if particle:IsA('ParticleEmitter') then
  83.                     particle.Enabled = false
  84.                 end
  85.             end
  86.         end
  87.     elseif RunService:IsClient() then
  88.        
  89.         local camShake = CameraShaker.new(Enum.RenderPriority.Camera.Value, function(shakeCFrame)
  90.         local cf = workspace.CurrentCamera.CFrame
  91.         workspace.CurrentCamera.CFrame = cf * shakeCFrame
  92.                     end)
  93.                    
  94.         camShake:Start()
  95.         wait(1)
  96.         -- Explosion shake:
  97.         for i = 1,10 do
  98.             camShake:Shake(CameraShaker.Presets.Earthquake)
  99.             wait(0.125)
  100.         end
  101.     end
  102.    
  103.     return true
  104.        
  105. end
  106.  
  107. if RunService:IsServer() then
  108.    
  109.     Info.FlyEffect = TweenInfo.new(1,Enum.EasingStyle.Linear)
  110.  
  111.     module.Requirements = {RequiredInputListeners={Enum.UserInputType.MouseButton1};
  112.                            RequireInputListener=true;
  113.                            RequireClientRender=true;
  114.                            RequireServerRender=true;
  115.                            RequiredInfo={'Mouse.Hit'}};
  116.    
  117.     function module.createAbilityManager()
  118.        
  119.         local manager = {Players={}}
  120.         manager.__index = manager
  121.        
  122.         function manager:CallSkill(player,info)
  123.             if not manager.Players[player] then
  124.                 manager.Players[player] = true
  125.                
  126.                 local waitForClientRender
  127.                 local waitForServerRender
  128.                
  129.                 if module.Requirements.RequireClientRender then
  130.                     spawn(function()
  131.                         waitForClientRender = Events.RequireSkill:InvokeClient(player,script.Name,info)
  132.                     end)
  133.                 else
  134.                     waitForClientRender = true
  135.                 end
  136.                
  137.                 if module.Requirements.RequireServerRender then
  138.                     waitForServerRender = renderSkill(player,info)
  139.                 else
  140.                     waitForServerRender = true
  141.                 end
  142.                
  143.                 repeat wait() until waitForServerRender and waitForClientRender
  144.                 manager.Players[player] = nil
  145.                
  146.             end
  147.         end
  148.        
  149.         return setmetatable(manager,module)
  150.        
  151.     end
  152.    
  153. elseif RunService:IsClient() then
  154.    
  155.     function module.renderSkill(info)
  156.         renderSkill(info)
  157.     end
  158.    
  159. end
  160.  
  161. return module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement