Er1x_Official

server script advanced fireball

Jan 23rd, 2022 (edited)
759
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.89 KB | None | 0 0
  1. local control = script.Parent
  2. local remote = control:WaitForChild("DAMNFIRE")
  3. local debris = game:GetService("Debris")
  4. local tween = game:GetService("TweenService")
  5. local TIN = TweenInfo.new
  6.  
  7. local animation -- keep this as it is
  8. local ballval = 0
  9. local holding = false
  10. local cooldown = false
  11. local cd_Time = 1
  12.  
  13. local charge = 0
  14. local maxcharge = 10 -- maximum charge
  15. local damage = 1 -- base damage * fireball charge damage
  16. local burndamage = 5 -- burn damage
  17.  
  18. function cvfx(ball:Instance)
  19.     local rando = math.random(5,8)
  20.     local a = Instance.new("Part",ball)
  21.     a.Shape = Enum.PartType.Ball
  22.     a.Material = Enum.Material.Neon
  23.     a.Size = Vector3.new(rando,rando,rando)
  24.     a.Name = "fireball-vfx"
  25.     a.Transparency = 1
  26.     a.Anchored = true
  27.     a.CanCollide = false
  28.     a.CanTouch = false
  29.     a.Massless = true
  30.     a.Parent = ball
  31.     a.Color = Color3.new(1,1,1)
  32.     a.CFrame = ball.CFrame
  33.    
  34.     local aud = script.chargeUp:Clone()
  35.     aud.Parent = ball
  36.     aud:Play()
  37.     debris:AddItem(aud,aud.TimeLength + 1)
  38.    
  39.     charge = charge + 1
  40.     tween:Create(a,TIN(1),{Color = ball.Color,Size = Vector3.new(.1,.1,.1),Transparency = 0}):Play()
  41.     ball:WaitForChild("ParticleEmitter"):Emit(math.random(1,5))
  42.     debris:AddItem(a,1.2)
  43. end
  44.  
  45. function velocity(Part,Speed,Start,End)
  46.     local vel = Instance.new("BodyVelocity",Part)
  47.     vel.Velocity = CFrame.new(Start,End).LookVector * Speed
  48.     vel.MaxForce = Vector3.new(5000,5000,5000)
  49.     vel.P = 10000
  50. end
  51.  
  52. function burn(Repeats,DamageDelay,Damage,Humanoid)
  53.     coroutine.wrap(function()
  54.         if Humanoid.Parent ~= nil then
  55.             local checkforpart = Humanoid.Parent:FindFirstChildOfClass("Part")
  56.             local particle = script.burnpe:Clone()
  57.             if checkforpart then
  58.                 local aud = script.burn:Clone()
  59.                 aud.Parent = Humanoid.Parent:FindFirstChildOfClass("Part")
  60.                 aud:Play();debris:AddItem(aud,aud.TimeLength + 1)
  61.             end
  62.  
  63.             for i = 1,Repeats do
  64.                 if Humanoid ~= nil and Humanoid.Parent ~= nil then
  65.                     Humanoid:TakeDamage(damage)
  66.                     checkforpart = Humanoid.Parent:FindFirstChildOfClass("Part")
  67.                     if checkforpart then
  68.                         local ouch = particle:Clone()
  69.                         ouch.Parent = Humanoid.Parent:FindFirstChildOfClass("Part")
  70.                         ouch:Emit(math.random(5,10))
  71.                         debris:AddItem(ouch,1)
  72.                     end
  73.                 end
  74.  
  75.                 task.wait(DamageDelay)
  76.             end
  77.         end
  78.     end)()
  79. end
  80.  
  81. remote.OnServerEvent:Connect(function(p,v,m)
  82.     local root = p.Character:FindFirstChild("HumanoidRootPart")
  83.     local humanoid = p.Character:FindFirstChildOfClass("Humanoid")
  84.    
  85.     if p.Character ~= nil and root and humanoid then
  86.         local animator = humanoid:FindFirstChildOfClass("Animator")
  87.         if cooldown == false and animator then
  88.             local info = string.lower(tostring(v))
  89.             if animation == nil then
  90.                 animation = animator:LoadAnimation(control:WaitForChild("Animations").Charge)
  91.             end
  92.            
  93.             if info == "fire" then
  94.                 cooldown = true
  95.                 coroutine.wrap(function()
  96.                     for l = 1,5 do -- repeat 3 times and stop animation
  97.                         animation:Stop()
  98.                         task.wait() -- a bit of delay
  99.                     end
  100.                 end)()
  101.                
  102.                 local totalDmg = damage * charge -- damage multiplied by charge
  103.                
  104.                 animator:LoadAnimation(control:WaitForChild("Animations").Fire):Play()
  105.                 local ball = root.Parent:FindFirstChild("fireball"..ballval)
  106.                
  107.                 if ball then
  108.                     local hasHit = false
  109.                    
  110.                     ball.ParticleEmitter:Emit(math.random(5,10))
  111.                     ball.Transparency = 1
  112.                     debris:AddItem(ball,1)
  113.                    
  114.                     local ball2 = ball:Clone()
  115.                     ball2.Joint:Destroy()
  116.                     ball2.Name = ball.Name.."_projectile"
  117.                     ball2.Parent = root.Parent
  118.                     ball2.Position = ball.Position
  119.                     ball2.Anchored = false
  120.                     ball2.Transparency = 0
  121.                    
  122.                     local aud = script.fire:Clone()
  123.                     aud.Parent = ball2
  124.                     aud:Play()
  125.                    
  126.                     debris:AddItem(aud,aud.TimeLength + 1)
  127.                     for _,c in next,ball2:GetChildren() do
  128.                         if c:IsA("Part") then
  129.                             c:Destroy()
  130.                         end
  131.                     end
  132.                    
  133.                     for f,j in next,root.Parent:GetChildren() do
  134.                         if string.match(j.Name,"fireball") then --and not string.match("projectile",j.Name) then
  135.                             if not string.match(j.Name,"projectile") then
  136.                                 if j ~= ball then
  137.                                     debris:AddItem(j,.5)
  138.                                     animation:Stop()
  139.                                 end
  140.                             end
  141.                         end
  142.                     end
  143.                    
  144.                     debris:AddItem(ball2,10)
  145.                     velocity(ball2,100,ball2.Position,m)
  146.                     ball2.Touched:Connect(function(hit)
  147.                         if hasHit == false then
  148.                             local IGNORENAME = {"BASE","Base","Baseplate"} -- ignored hit parts name
  149.                             if hit and not table.find(IGNORENAME,hit.Name) then
  150.                                 if hit.Parent ~= root.Parent and not string.match(hit.Name,"projectile") and not string.match(hit.Name,"vfx") then
  151.                                     hasHit = true
  152.                                    
  153.                                     local ehum = hit.Parent:FindFirstChildOfClass("Humanoid") or hit.Parent.Parent:FindFirstChildOfClass("Humanoid")
  154.                                     if ehum and ehum ~= humanoid then
  155.                                         ehum:TakeDamage(totalDmg)
  156.                                         burn(5,1,burndamage,ehum)
  157.                                     end
  158.  
  159.                                     tween:Create(ball2,TIN(.45),{Transparency = 1,Size = Vector3.new(5,5,5)}):Play()
  160.                                     debris:AddItem(ball2,.5)
  161.                                 end
  162.                             end
  163.                         end
  164.                     end)
  165.                 end
  166.                
  167.                 task.delay(cd_Time,function()
  168.                     cooldown = false
  169.                     charge = 0
  170.                 end)
  171.             elseif info == "holding" then
  172.                 if holding == false then
  173.                     holding = true
  174.                     local ball = root.Parent:FindFirstChild("fireball"..ballval)
  175.                     if ball then
  176.                         if charge < maxcharge then
  177.                             cvfx(ball) 
  178.                             charge = charge + 1
  179.                         end
  180.                     end
  181.                    
  182.                     task.delay(.5,function()
  183.                         holding = false
  184.                     end)
  185.                 end
  186.             elseif info == "start" then
  187.                 if cooldown == false then
  188.                     local ball = script:WaitForChild("fireball"):Clone()
  189.                    
  190.                     ballval = ballval + 1
  191.                     ball.Parent = root.Parent
  192.                     ball.Name = ball.Name..ballval
  193.                     ball.Joint.Part0 = root.Parent:FindFirstChild("Right Arm")
  194.                     task.delay(.1,function()
  195.                         if holding == true then
  196.                             animation:Play()
  197.                         end
  198.                     end)
  199.                 end
  200.             end
  201.         end
  202.     end
  203. end)
Add Comment
Please, Sign In to add comment