Advertisement
Guest User

asd

a guest
Aug 24th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.57 KB | None | 0 0
  1. local Player = game.Players.LocalPlayer
  2.  
  3. function GraphicalEffects.CrystalRing(data)
  4. data = data or {}
  5. local crystal_count = data.crystal_count or 10
  6. local crystal_color = data.crystal_color or BrickColor.new("Bright red")
  7. local crystal_scale = data.crystal_scale or Vector3.new(2 / 3, 2, 2 / 3)
  8. local fade_out_color = data.fade_out_color or BrickColor.new("Really black")
  9. local radius = radius or 1.25 * crystal_count / math.pi
  10. local spawn_duration = data.spawn_duration or 0.065
  11. local full_spawn_duration = spawn_duration * crystal_count
  12. local float_duration = data.float_duration or 5
  13. local wave_amplitude = data.wave_amplitude or 0.5
  14. local wave_period = data.wave_period or 1
  15. local appear_duration = data.appear_duration or 0.1
  16. local disappear_duration = data.disappear_duration or 0.5
  17. local base_part = data.base_part
  18. local offset_cframe
  19. if data.position then
  20. offset_cframe = CFrame.new(data.position)
  21. if base_part then
  22. offset_cframe = base_part.CFrame:toObjectSpace(offset_cframe)
  23. end
  24. else
  25. offset_cframe = CFrame.new()
  26. end
  27. local crystal_template = Instance.new("Part")
  28. crystal_template.Anchored = true
  29. crystal_template.Locked = true
  30. crystal_template.CanCollide = false
  31. crystal_template.BottomSurface = "Smooth"
  32. crystal_template.TopSurface = "Smooth"
  33. crystal_template.BrickColor = crystal_color
  34. crystal_template.FormFactor = "Symmetric"
  35. crystal_template.Size = Vector3.new(1, 1, 1)
  36. local crystal_light = Instance.new("PointLight", crystal_template)
  37. crystal_light.Brightness = 0.1 / crystal_count
  38. crystal_light.Color = crystal_color.Color
  39. crystal_light.Name = "Light"
  40. crystal_light.Range = radius
  41. crystal_light.Shadows = true
  42. local crystal_mesh = Instance.new("SpecialMesh", crystal_template)
  43. crystal_mesh.MeshId = "rbxassetid://9756362"
  44. crystal_mesh.MeshType = "FileMesh"
  45. crystal_mesh.Name = "Mesh"
  46. crystal_mesh.Scale = crystal_scale
  47. local crystal_model = Instance.new("Model")
  48. crystal_model.Archivable = false
  49. crystal_model.Name = "Crystal Model"
  50. crystal_model.Parent = Workspace
  51. local crystals = {}
  52. local lights = {}
  53. local meshes = {}
  54. for index = 1, crystal_count do
  55. local crystal = crystal_template:Clone()
  56. crystal.Parent = crystal_model
  57. crystals[index] = crystal
  58. lights[index] = crystal.Light
  59. meshes[index] = crystal.Mesh
  60. end
  61. local start_time = tick()
  62. repeat
  63. local base_cframe = offset_cframe
  64. if base_part then
  65. base_cframe = base_part.CFrame * base_cframe
  66. end
  67. local elapsed_time = tick() - start_time
  68. for index, crystal in ipairs(crystals) do
  69. local crystal_time = elapsed_time - index * spawn_duration
  70. local disappear_time = crystal_time - float_duration
  71. local offset
  72. if crystal_time < 0 then
  73. offset = 0
  74. elseif crystal_time < appear_duration then
  75. offset = radius * crystal_time / appear_duration
  76. else
  77. offset = radius
  78. end
  79. local wave_offset
  80. if disappear_time >= 0 then
  81. local disappear_progress = disappear_time / disappear_duration
  82. if disappear_progress > 1 then
  83. if crystal.Parent then
  84. crystal:Destroy()
  85. end
  86. else
  87. local inverse_progress = 1 - disappear_progress
  88. local light = lights[index]
  89. local mesh = meshes[index]
  90. crystal.BrickColor = fade_out_color
  91. light.Brightness = 2 * inverse_progress
  92. light.Range = 2 * radius
  93. mesh.Scale = crystal_scale * inverse_progress
  94. end
  95. wave_offset = 0
  96. else
  97. wave_offset = wave_amplitude * math.sin(math.tau * (elapsed_time - index / crystal_count * 3) / wave_period)
  98. end
  99. local rotation_angle = (tick() * 0.5 + (index - 1) / crystal_count) % 1 * math.tau
  100. crystal.CFrame = base_cframe * CFrame.Angles(0, rotation_angle, 0) * CFrame.new(0, wave_offset, -offset)
  101. end
  102. RunService.Stepped:wait()
  103. until elapsed_time >= float_duration + full_spawn_duration + disappear_duration
  104. if crystal_model.Parent then
  105. crystal_model:Destroy()
  106. end
  107. end
  108.  
  109. GraphicalEffects.CrystalRing({base_part=Player.Character.Torso, crystal_color = BrickColor.new("New Yeller"), fade_out_color = BrickColor.new("Instituational White"),float_duration = 0.2})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement