Advertisement
NebulaZorua

effect function lol

Mar 22nd, 2018
442
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.57 KB | None | 0 0
  1. function Bezier(startpos, pos2, pos3, endpos, t)
  2. local A = startpos:lerp(pos2, t)
  3. local B = pos2:lerp(pos3, t)
  4. local C = pos3:lerp(endpos, t)
  5. local lerp1 = A:lerp(B, t)
  6. local lerp2 = B:lerp(C, t)
  7. local cubic = lerp1:lerp(lerp2, t)
  8. return cubic
  9. end
  10.  
  11. function Effect(data)
  12. local FX = data.Effect or 'ResizeAndFade'
  13. local Parent = data.Parent or Effects
  14. local Color = data.Color or C3.N(0,0,0)
  15. local Size = data.Size or V3.N(1,1,1)
  16. local MoveDir = data.MoveDirection or nil
  17. local MeshData = data.Mesh or nil
  18. local SndData = data.Sound or nil
  19. local Frames = data.Frames or 45
  20. local Manual = data.Manual or nil
  21. local Material = data.Material or nil
  22. local CFra = data.CFrame or Torso.CFrame
  23. local Settings = data.FXSettings or {}
  24. local Snd,Prt,Msh;
  25. if(Manual and typeof(Manual) == 'Instance' and Manual:IsA'BasePart')then
  26. Prt = Manual
  27. else
  28. Prt = Part(Parent,Color,Material,Size,CFra,true,false)
  29. end
  30. if(typeof(MeshData) == 'table')then
  31. Msh = Mesh(Prt,MeshData.MeshType,MeshData.MeshId,MeshData.TextureId,MeshData.Scale,MeshData.Offset)
  32. elseif(typeof(MeshData) == 'Instance')then
  33. Msh = MeshData:Clone()
  34. Msh.Parent = Prt
  35. end
  36. if(typeof(SndData) == 'table' or typeof(SndData) == 'Instance')then
  37. Snd = Sound(Prt,SndData.SoundId,SndData.Pitch,SndData.Volume,false,false,true)
  38. end
  39. if(Snd)then
  40. repeat wait() until Snd.Playing and Snd.IsLoaded and Snd.TimeLength > 0
  41. Frames = Snd.TimeLength * Frame_Speed/Snd.Pitch
  42. end
  43. local MoveSpeed = nil;
  44. if(MoveDir)then
  45. MoveSpeed = (CFra.p - MoveDir).magnitude/Frames
  46. end
  47. local Inc = M.RNG()-M.RNG()
  48. local Thingie = 0
  49. local Thingie2 = M.RNG(50,100)/100
  50.  
  51. coroutine.resume(coroutine.create(function()
  52. if(FX ~= 'Arc')then
  53. for i = 1, Frames do
  54. if(FX == 'ResizeAndFade')then
  55. if(not Settings.EndSize)then
  56. Settings.EndSize = V3.N(0,0,0)
  57. end
  58. local grow = (typeof(Settings.EndSize) == 'Vector3' and Settings.EndSize+Size or typeof(Settings.EndSize) == 'number' and V3.N(Settings.EndSize))
  59. if(Settings.EndIsIncrement)then
  60. Prt.Size = Prt.Size + Settings.EndSize
  61. else
  62. Prt.Size = Prt.Size - grow/Frames
  63. end
  64. Prt.Transparency = (i/Frames)
  65. elseif(FX == 'Fade')then
  66. Prt.Transparency = (i/Frames)
  67. end
  68. if(Settings.RandomizeCFrame)then
  69. Prt.CFrame = Prt.CFrame * CF.A(M.RRNG(-360,360),M.RRNG(-360,360),M.RRNG(-360,360))
  70. end
  71. if(MoveDir and MoveSpeed)then
  72. local Orientation = Prt.Orientation
  73. Prt.CFrame = CF.N(Prt.Position,MoveDir)*CF.N(0,0,-MoveSpeed)
  74. Prt.Orientation = Orientation
  75. end
  76. if(swait and typeof(swait) == 'function')then
  77. swait()
  78. else
  79. wait()
  80. end
  81. end
  82. Prt:destroy()
  83. else
  84. local start,third,fourth,endP = Settings.Start,Settings.Third,Settings.Fourth,Settings.End
  85. if(not Settings.End and Settings.Home)then endP = Settings.Home.CFrame end
  86. local quarter = third or start:lerp(endP, 0.25) * CF.N(M.RNG(-25,25),M.RNG(0,25),M.RNG(-25,25))
  87. local threequarter = fourth or start:lerp(endP, 0.75) * CF.N(M.RNG(-25,25),M.RNG(0,25),M.RNG(-25,25))
  88. assert(start ~= nil,"You need to specify a start point!")
  89. assert(endP ~= nil,"You need to specify an end point!")
  90. for i = 0, 1, Settings.Speed or 0.01 do
  91. if(Settings.Home)then
  92. endP = Settings.Home.CFrame
  93. end
  94. Prt.CFrame = Bezier(start, quarter, threequarter, endP, i)
  95. if(swait and typeof(swait) == 'function')then
  96. swait()
  97. else
  98. wait()
  99. end
  100. end
  101. if(Settings.RemoveOnGoal)then
  102. Prt:destroy()
  103. end
  104. end
  105. end))
  106. return Prt,Msh,Snd
  107. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement