Modifiers
Modifiers are a powerful tool that allows you to define per cast functionality seperate from the base projectile definition.
They can be used to alter already existing projectile definitions for example: Giving a grenade extra velocity for jump/run throws.
Danger
When using Modifiers make sure that all clients and the server use the same modifier, improper modifier usage can result in simulation desync.
Example
I will be using the simulation setup from the previous page, if you haven't setup your simulaton yet refer to the previous page.
In this example we will create a modifier that gives a bullet extra penetrative power, this modifier will be controlled by an attribute "ExtraPenetration" in the players character.
Example client simulation with modifiers
...
UserInputService.InputBegan:Connect(function(Input, GPE)
...
local ProjectileModifier;
if Character:GetAttribute("ExtraPenetration") then
ProjectileModifier = {
Power = 200,
Extra = {
Weapon = "M16"
}
}
end
local Time = workspace:GetServerTimeNow()
--> Replicate to the server
SimulateEvent:FireServer(Origin, Direction, Time)
--> Cast the projectile within our own simulation
SecureCast.Cast(Player, "Bullet", Origin, Direction, Time, nil, ProjectileModifier)
end)
...