Skip to content

Instantly share code, notes, and snippets.

@Elmuti
Created September 12, 2023 15:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Elmuti/6d011cb6ad0c4fa33b72bb4e2a7a1959 to your computer and use it in GitHub Desktop.
Save Elmuti/6d011cb6ad0c4fa33b72bb4e2a7a1959 to your computer and use it in GitHub Desktop.
local ExpandingBeamCylinderEffect = {}
local function Lerp(start, goal, alpha)
return start * (1 - alpha) + goal * alpha
end
local function TweenFlameEffectTransparency(effect, endtransparency, duration)
local alpha = 0
local t = 0
while t < duration do
local dt = game:GetService("RunService").RenderStepped:wait()
local alpha = t / duration
t = t + dt
local lbt = Lerp(effect.LeftBack.Transparency.Keypoints[1].Value, endtransparency, alpha)
local lft = Lerp(effect.LeftFront.Transparency.Keypoints[1].Value, endtransparency, alpha)
local rbt = Lerp(effect.RightBack.Transparency.Keypoints[1].Value, endtransparency, alpha)
local rft = Lerp(effect.RightFront.Transparency.Keypoints[1].Value, endtransparency, alpha)
effect.LeftBack.Transparency = NumberSequence.new(lbt, lbt)
effect.LeftFront.Transparency = NumberSequence.new(lft, lft)
effect.RightBack.Transparency = NumberSequence.new(rbt, rbt)
effect.RightFront.Transparency = NumberSequence.new(rft, rft)
end
end
local function TweenFlameEffect(effect, endradius, endwidth, endtransparency, duration)
local alpha = 0
local t = 0
game.Debris:AddItem(effect.back, duration)
game.Debris:AddItem(effect.front, duration)
game.Debris:AddItem(effect.left, duration)
game.Debris:AddItem(effect.right, duration)
game.Debris:AddItem(effect.LeftBack, duration)
game.Debris:AddItem(effect.LeftFront, duration)
game.Debris:AddItem(effect.RightBack, duration)
game.Debris:AddItem(effect.RightFront, duration)
while t < duration do
local dt = game:GetService("RunService").RenderStepped:wait()
local alpha = t / duration
t = t + dt
effect.back.Position = Vector3.new(0, 0, Lerp(effect.back.Position.Z, endradius, alpha))
effect.front.Position = Vector3.new(0, 0, Lerp(effect.front.Position.Z, -endradius, alpha))
effect.left.Position = Vector3.new(Lerp(effect.left.Position.X, endradius, alpha), 0, 0)
effect.right.Position = Vector3.new(Lerp(effect.right.Position.X, -endradius, alpha), 0, 0)
effect.LeftBack.CurveSize0 = Lerp(effect.LeftBack.CurveSize0, endradius, alpha)
effect.LeftFront.CurveSize1 = Lerp(effect.LeftFront.CurveSize1, -endradius, alpha)
effect.RightBack.CurveSize1 = Lerp(effect.RightBack.CurveSize1, endradius, alpha)
effect.RightFront.CurveSize0 = Lerp(effect.RightFront.CurveSize0, -endradius, alpha)
effect.LeftBack.Width0 = Lerp(effect.LeftBack.Width0, endwidth, alpha)
effect.LeftFront.Width0 = Lerp(effect.LeftFront.Width0, endwidth, alpha)
effect.RightBack.Width0 = Lerp(effect.RightBack.Width0, endwidth, alpha)
effect.RightFront.Width0 = Lerp(effect.RightFront.Width0, endwidth, alpha)
effect.LeftBack.Width1 = Lerp(effect.LeftBack.Width1, endwidth, alpha)
effect.LeftFront.Width1 = Lerp(effect.LeftFront.Width1, endwidth, alpha)
effect.RightBack.Width1 = Lerp(effect.RightBack.Width1, endwidth, alpha)
effect.RightFront.Width1 = Lerp(effect.RightFront.Width1, endwidth, alpha)
end
end
local function TweenFlameEffectAsync(...)
local t = {...}
spawn(function()
TweenFlameEffect(unpack(t))
end)
end
local function TweenFlameEffectTransparencyAsync(...)
local t = {...}
spawn(function()
TweenFlameEffectTransparency(unpack(t))
end)
end
local function CreateFlameAoeEffect(parent, color)
local effect = {}
effect.StartRadius = 1
effect.back = Instance.new("Attachment")
effect.front = Instance.new("Attachment")
effect.left = Instance.new("Attachment")
effect.right = Instance.new("Attachment")
effect.LeftBack = Instance.new("Beam")
effect.LeftFront = Instance.new("Beam")
effect.RightBack = Instance.new("Beam")
effect.RightFront = Instance.new("Beam")
effect.back.Name = "Back"
effect.front.Name = "Front"
effect.left.Name = "Left"
effect.right.Name = "Right"
effect.LeftBack.Name = "LeftBack"
effect.LeftFront.Name = "LeftFront"
effect.RightBack.Name = "RightBack"
effect.RightFront.Name = "RightFront"
effect.back.Position = Vector3.new(0, 0, effect.StartRadius)
effect.front.Position = Vector3.new(0, 0, -effect.StartRadius)
effect.left.Position = Vector3.new(effect.StartRadius, 0, 0)
effect.right.Position = Vector3.new(-effect.StartRadius, 0, 0)
for _, beam in pairs({effect.LeftBack,effect.LeftFront,effect.RightBack,effect.RightFront}) do
beam.Color = ColorSequence.new(color or Color3.fromRGB(255, 59, 0), color or Color3.fromRGB(255, 59, 0))
beam.LightEmission = 1
beam.Texture = ""
beam.TextureSpeed = 0
beam.TextureMode = Enum.TextureMode.Stretch
beam.Transparency = NumberSequence.new(0, 0)
beam.Segments = 10
beam.Width0 = 10
beam.Width1 = 10
end
effect.LeftBack.CurveSize0 = -1
effect.LeftFront.CurveSize1 = 1
effect.RightBack.CurveSize1 = -1
effect.RightFront.CurveSize0 = 1
effect.LeftBack.Attachment0 = effect.back
effect.LeftFront.Attachment0 = effect.left
effect.RightBack.Attachment0 = effect.right
effect.RightFront.Attachment0 = effect.front
effect.LeftBack.Attachment1 = effect.left
effect.LeftFront.Attachment1 = effect.front
effect.RightBack.Attachment1 = effect.back
effect.RightFront.Attachment1 = effect.right
effect.back.Parent = parent
effect.front.Parent = parent
effect.left.Parent = parent
effect.right.Parent = parent
effect.LeftBack.Parent = parent
effect.LeftFront.Parent = parent
effect.RightBack.Parent = parent
effect.RightFront.Parent = parent
return effect
end
local function CastFireCircleEffect(root, endradius, endwidth, endtransparency, duration, color)
local effect = CreateFlameAoeEffect(root, color)
local emitter = game.ReplicatedStorage.Particles.LevelUp:Clone()
emitter.Parent = root
TweenFlameEffectAsync(effect, endradius, endwidth, endtransparency, duration)
TweenFlameEffectTransparencyAsync(effect, 1, duration)
wait()
emitter:Emit(10)
game.Debris:AddItem(emitter, duration)
end
ExpandingBeamCylinderEffect.TweenFlameEffectTransparency = TweenFlameEffectTransparency
ExpandingBeamCylinderEffect.TweenFlameEffect = TweenFlameEffect
ExpandingBeamCylinderEffect.TweenFlameEffectAsync = TweenFlameEffectAsync
ExpandingBeamCylinderEffect.TweenFlameEffectTransparencyAsync = TweenFlameEffectTransparencyAsync
ExpandingBeamCylinderEffect.CreateFlameAoeEffect = CreateFlameAoeEffect
ExpandingBeamCylinderEffect.CastFireCircleEffect = CastFireCircleEffect
return ExpandingBeamCylinderEffect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment