Info
This Module is used for making the Area Effects more easier with just 1-2 lines of code! This Module is also modular that means that you can edit how the Effect will emit. For now you can only emit Circular / Straight Line effects but you can also add your own Shapes to the module!
Once you put the module in ur game you need to require it by Script/LocalScript
Showcase
Circle :
One Line :
Links
RBLX Model - here
Example Code
local AreaEffectModule = require(game.ReplicatedStorage.AreaEffect) --> Module
local Container = Instance.new("Folder",workspace) --> Instance where all of the Segments will be stored
Container.Name = "Container"
local DefaultRaycastParams = RaycastParams.new()
DefaultRaycastParams.FilterType = Enum.RaycastFilterType.Exclude
DefaultRaycastParams.IgnoreWater = true
DefaultRaycastParams.FilterDescendantsInstances = {}
local behavior = AreaEffectModule.newBehavior() --> The Settings of the Effect
behavior.Debug = true --> Set this to true if u want the module to Debug unnesessary errors. (Not Recommended)
behavior.Lifetime = 1 --> The life time of the Segments
behavior.Segments = 7 --> Amount Of Segments that will be emitted. This can also be a function
--[[
behavior.Segments = function(mod : number, segments : number, index : number)
return number
end
]]
behavior.TweenInfo_OUT = TweenInfo.new(.03,Enum.EasingStyle.Quad,Enum.EasingDirection.Out,0,false,0) --> Tween Info for starter tween
behavior.TweenInfo_IN = TweenInfo.new(.5,Enum.EasingStyle.Quad,Enum.EasingDirection.In,0,false,0) --> Tween Info for finish tween
behavior.Shape = AreaEffectModule.AreaShapes["Circle"] --> The Shape of the Effect
behavior.Formulas = AreaEffectModule.AreaShapeFormulas[behavior.Shape] --> Formulas that will be applied to parts when emitting. Note : Formulas can be changed
behavior.raycast = { --> Table of workspace:Raycast() properties. Note : This raycast is for checking if there's ground below the Origin CFrame, you can also not change this since there's already a template in the module.
originOffset = Vector3.new(0,3,0); --> The offset from the origin offset
direction = Vector3.new(0,-10,0); --> The direction of the ray
params = DefaultRaycastParams; --> RaycastParams for the ray
}
behavior.SegmentFinalPositionMinusY = .7 --> Segment's Origin Position.Y will be affected by this property
behavior.Mod = 1 --> How many times will the effect emit
behavior.TimeEachMode = 0.03 --> The delay between each emit
behavior.Container = Container --> Where the Segments will be stored
--> behavior.PartTemplate = Instance.new("Part") --> You can also not change this because the module will create the part automaticly when emitted
--behavior.Formulas.ModAmountsFormula = function(segments : number, mod : number, index : number) --> Add this if u want the amounts of times the effect will emit to not change by default.
-- return mod
--end
while task.wait(behavior.Lifetime*1.5) do
AreaEffectModule.Emit(CFrame.new(0, 0, 0), behavior) --> Emit the Effect.
end
--> or
AreaEffectModule.Emit(CFrame.new(0,0,0)) --> If u do this then the behavior will be set by default.
Formulas
local function random(min : number, max : number, j : number)
return math.random(min*j,max*j)/j
end
local AreaShapeFormulas = {
["Circle"] = {
ModAmountsFormula = function(segments : number, mod : number, index : number)
assert(mod, "[AreaEffect] Expected mod got nil")
return (20 * mod)/10
end,
SegmentsRotationFormula = function(segments : number, mod : number, index : number)
assert(segments, "[AreaEffect] Expected segments got nil")
assert(index, "[AreaEffect] Expected index got nil")
return CFrame.Angles(0,math.rad(360/segments) * index,0)
end,
SegmentsOffsetFormula = function(segments : number, mod : number, index : number)
assert(mod, "[AreaEffect] Expected mod got nil")
assert(index, "[AreaEffect] Expected index got nil")
return CFrame.new(0,0,(index * -(25 * mod)/3) - 2)
end,
SegmentSizeFormula = function(segments : number, mod : number, index : number)
assert(mod, "[AreaEffect] Expected mod got nil")
assert(segments, "[AreaEffect] Expected segments got nil")
return Vector3.new(random(4,6,1) * 15 * mod/segments, random(3,5,1), random(5,10,1))
end,
SegmentYoffset = function(segments : number, mod : number, index : number)
return Vector3.new(0,5,0)
end,
SegmentAnglesOffset = function(segments : number, mod : number, index : number)
return CFrame.Angles(math.rad(random(10,45,1)),0,0)
end,
};
["OneLine"] = {
ModAmountsFormula = function(segments : number, mod : number, index : number)
assert(mod, "[AreaEffect] Expected mod got nil")
return mod --(20 * mod)/10
end,
SegmentsRotationFormula = function(segments : number, mod : number, index : number)
assert(segments, "[AreaEffect] Expected segments got nil")
assert(index, "[AreaEffect] Expected index got nil")
return CFrame.Angles(0,0,0)
end,
SegmentsOffsetFormula = function(segments : number, mod : number, index : number)
assert(mod, "[AreaEffect] Expected mod got nil")
assert(index, "[AreaEffect] Expected index got nil")
return CFrame.new(0,0,mod + (segments * (index*6))/segments)
end,
SegmentSizeFormula = function(segments : number, mod : number, index : number)
assert(mod, "[AreaEffect] Expected mod got nil")
assert(segments, "[AreaEffect] Expected segments got nil")
local size = random(4,6,1)
return Vector3.new(size,size,size)
end,
SegmentYoffset = function(segments : number, mod : number, index : number)
return Vector3.new(0,6,0)
end,
SegmentAnglesOffset = function(segments : number, mod : number, index : number)
local min_angles = -90
local max_angles = 90
return CFrame.Angles(math.rad(random(min_angles,max_angles,1)),math.rad(random(min_angles,max_angles,1)),math.rad(random(min_angles,max_angles,1)))
end,
};
};
Also this Module is free to use!
Iāll try to add more shapes to the Module in the future! For now feel free to use this.
Updates
- Added new Shape called āOneLineā
- Now the module is even more Modular!
- Fixed the Cirlce Shape
- Fixed the āBehavior Tableā Cloning
āOne Lineā Shape Example Code
local AreaEffectModule = require(game.ReplicatedStorage.AreaEffect) --> Module
local Container = Instance.new("Folder",workspace) --> Instance where all of the Segments will be stored
Container.Name = "Container"
local DefaultRaycastParams = RaycastParams.new()
DefaultRaycastParams.FilterType = Enum.RaycastFilterType.Exclude
DefaultRaycastParams.IgnoreWater = true
DefaultRaycastParams.FilterDescendantsInstances = {}
local behavior = AreaEffectModule.newBehavior() --> The Settings of the Effect
behavior.Debug = false --> Set this to true if u want the module to Debug unnesessary errors. (Not Recommended)
behavior.Lifetime = 1 --> The life time of the Segments
behavior.Segments = 50 --> Amount Of Segments that will be emitted / The Length of the effect. This can also be a function
--[[
behavior.Segments = function(mod : number, segments : number, index : number)
return number
end
]]
behavior.TweenInfo_OUT = TweenInfo.new(.05,Enum.EasingStyle.Quad,Enum.EasingDirection.Out,0,false,0) --> Tween Info for starter tween
behavior.TweenInfo_IN = TweenInfo.new(.5,Enum.EasingStyle.Quad,Enum.EasingDirection.In,0,false,0) --> Tween Info for finish tween
behavior.Shape = AreaEffectModule.AreaShapes["OneLine"] --> The Shape of the Effect
behavior.Formulas = AreaEffectModule.AreaShapeFormulas[behavior.Shape] --> Formulas that will be applied to parts when emitting. Note : Formulas can be changed
behavior.raycast = { --> Table of workspace:Raycast() properties. Note : This raycast is for checking if there's ground below the Origin CFrame, you can also not change this since there's already a template in the module.
originOffset = Vector3.new(0,3,0); --> The offset from the origin offset
direction = Vector3.new(0,-10,0); --> The direction of the ray
params = DefaultRaycastParams; --> RaycastParams for the ray
}
behavior.SegmentFinalPositionMinusY = 1 --> Segment's Origin Position.Y will be affected by this property
behavior.Mod = 2 --> How many times will the effect emit
behavior.TimeEachMode = 0.01 --> The delay between each emit
behavior.Container = Container --> Where the Segments will be stored
--> behavior.PartTemplate = Instance.new("Part") --> You can also not change this because the module will create the part automaticly when emitted
--behavior.Formulas.ModAmountsFormula = function(mod : number, segments : number) --> Add this if u want the amounts of times the effect will emit to not change by default.
-- return mod
--end
while task.wait(behavior.Lifetime*1.5) do
AreaEffectModule.Emit(CFrame.new(0, 0, 0), behavior) --> Emit the Effect.
end