This page lists down functions used for commonly used for VFX by all classes, which may also include functions used in actual moves themselves (this is not a BM2 framework functions listings)
General framework
These are functions that each class uses in its VFX module.
Calling the module
local Lib = require(game.ReplicatedStorage.Modules.LibraryModule)
local Library = Lib()
Visual effects
These functions are used to make visual effects.
Library.CreateEffect
Creates a part with a mesh associated with it and tweens the part.
Library.CreateEffect(PartProperties, Goals, TweenInfo, BetFunc, EndFunc)
-- Example usage
Library.CreateEffect(
-- Part properties, this is the part being created
{
MeshId = Resources.Meshes.WindMesh.MeshId,
CFrame = cfo,
Color = Color3.new(1, 1, 1),
Scale = Vector3.new(radius1 / 2, 1, radius1 / 2),
Offset = Vector3.new(-radius1, 0.25, 0)
},
-- This is the final outcome of the part, the goal
{
Transparency = 1,
Scale = Vector3.new(radius2 / 2, 1, radius2 / 2),
Offset = Vector3.new(-radius2, 0.25, 0),
CFrame = cfo * CFrame.Angles(0, math.rad(180), 0)
},
-- TweenInfo, which can be anything (in this case 0.4 second transition)
TweenInfo.new(0.4),
-- BetFunc, which is a function ran in the middle of the tween. Optional.
function(p, m)
p.CFrame = p.CFrame * CFrame.Angles(0, 0, 0)
end
-- There is EndFunc which runs at the end of the tween, but it's not
-- used quite often. EndFunc is also optional.
)
Some settings can get a bit abstract.
Library.CloneEffect
Clones an effect to workspace.
Library.CloneEffect(FXLocation, Properties, Goals, TweenInfo, Betfunc, EndFunc)
-- Example usage
Library.CloneEffect(
-- FX location
Resources.MeshParts.AssailantCres,
-- Properties of this mesh
{
-- Set from HumanoidRootPart
CFrame = User["HumanoidRootPart"].CFrame * CF,
Transparency = 1,
Material = "Neon",
Color = Colors[2],
Anchored = true,
CanCollide = false
},
-- The "goal" of the tween, in this case to reach transpareny of 0.7
{
Transparency = 0.7
},
-- How it's tweened
-- Factor variable is FPS factor. See Library.GetFPSFactor
TweenInfo.new(0.3 / Factor),
-- BetFunc, runs during the tween
function() end,
-- EndFunc, runs after the ween
function(p)
-- See Library.Tween for usage
Library.Tween(
p, TweenInfo.new(0.2 / Factor),
{
Transparency = 1, Size = p.Size * Vector3.new(1, 1, 0)
}
)
end
)
Library.Tween
Tweens an object. Somewhat similar to CreateEffect.
Library.Tween(Instance, TweenInfo, Goal, BetFunc, EndFunc, S1, S2)
-- S1 is an arguement passed to BetFunc
-- S2 is an arguement passed to EndFunc
-- Example usage
Library.Tween(
p, -- Instance
-- TweenInfo
TweenInfo.new(0.5 / Factor),
-- The goal
{
CFrame = cf * CFrame.new(0, 0, -10)
},
-- BetFunc, which is a function ran in the middle of the tween. Optional.
nil,
-- EndFunc, which is a function ran at the end of the tween. Optional.
function()
for i, v in pairs(fires) do
v.Enabled = false
game.Debris:AddItem(p, 3)
end
end
--[[
S1 and S2 are arguements passed.
Consider this:
local function BetFunc(color)
part.BrickColor = color
end
local S1 = {BrickColor.new("Bright blue")}
]]
)
Library.Create
Creates an object. A few other functions depend on this function.
Library.Create(Instance, Properties, DebrisTime)
-- Example usage
Library.Create(
"Attachment", -- The type of object to create (instance)
-- The properties of an attachment
{
Position = Vector3.new(0.5, -1, 0),
Parent = User["Right Leg"]
}
-- DebrisTime is optional
)
Library.PlayCutscene
Used for playing cutscenes, such as Assailant's execution.
Library.PlayCutscene(CFrame, FocusCFrame, Time, Delay)
-- Example usage
Library.PlayCutscene(
User.HumanoidRootPart.CFrame * CFrame.new(-4,3,3), -- CFRame
User.HumanoidRootPart.CFrame * CFrame.new(2,-1,0), -- FocusCFrame
0.3, -- Time
"Keep" -- Delay
)
CFrames are usually set relative to the humanoid's root part. Delay may also simply be "Keep" if no delay needs to be specified.
Commonly used utilities
These functions are also used in VFX modules.
Library.GetFPSFactor
Get's a player's FPS factor. Needed for timing things correctly. To fully understand what it does:
-- Where _G.DefaultFPS = 60
function Library.GetFPSFactor(Character)
if Character:FindFirstChild("Conditions") then
return Character.Conditions.FPS.Value / _G.DefaultFPS
end
end
The function returns a numerical value. Example usage:
Library.RunFor(Time, Function)
-- Example usage
task.spawn(function() -- Spawn a new thread
Library.RunFor(
0.3, -- Time the function runs for
function(t) -- The actual function itself
for i, b in pairs(beams) do
b.Transparency = NumberSequence.new(math.clamp(t, 0, 1))
end
end)
end
)
Library.InView
Checks to see if a specified position is within view.
Library.InView(Position, MaxZ) -- Max Z coordinate
-- Exapmle usage
Library.InView(Target.Head.Position, 100)
Library.RandomAngle
Returns a random angle. If the minimum or maximum angle is not specified, by default the minimum and maximum angles returns will be -360 degrees to 360 degrees respectively in radians.
Library.RandomAngle(MinAngle, MaxAngle) -- Give angles in DEGREES, not rads
-- Example usage
Library.RandomAngle() -- This is how it's most commonly called
Library.NumLerp
Does between the variables a and b, with c being the interpolation factor.
function Library.NumLerp(a, b, c)
return a + (b - a) * c
end
Library.NumLerp(a, b, c)
-- Example usage with a part
for i=1,30 do
...
p.Transparency = Library.NumLerp(transparency, 1, i/30)
end
Library.FindFloor
Used to find if there is a surface by raycasting. To fully understand what it does, since it does return two arguements:
function Library.FindFloor(Pos, Dir, Range)
if Dir == "Down" then
Dir = CFrame.new(Pos, Pos - Vector3.new(0, 1, 0)).lookVector
end
-- Only parts within _G.WorldCollisions can be raycasted on
return workspace:FindPartOnRayWithWhitelist(Ray.new(Pos, Dir.unit * Range), _G.WorldCollisions)
end
Library.FindFloor(Position, Direction, Range)
-- Example usage
-- The raycast will be pointing "down"
local floor, pos = Library.FindFloor(User.HumanoidRootPart.Position, "Down", 5)
if floor then
print("floor found: " .. floor.Name)
print("position: " .. tostring(pos))
end