LINKS
NOTE
This tutorial was made for a gun kit available in the creator marketplace and not a scripting guide, if you’re using FE Gun kit Viewmodel 2
or older version, consider swapping to the latest version in order to find this feature as i do not ship it in the older.
ConditionableMods allows you to edit stats from existing settings triggered from custom behavior, it can be used as Alt fire without having to make another setting module for it, or you can use it as alternative actions.
Setting up the Value from existing settings
ConditionableMods has 3 tables listed here
- Settings - Every settings that exists in the main stats module can be modified during shot
- Mods - Multiplies existing value from the settings, as stated in the comment, it must be a number to multiply
- Adds - adds a new value settings that does not exists, not sure how you’ll get that
in Settings
we’ll start with adding some existing settings, let’s say i wanted a fast and slow bullet mods, i can just use Firerate in the table and i want to change sound during alternative fires, it should be like this,
["fast_bullet"] = {
Settings = {
Auto = true;
FireRate = 0.085;
FireSound = "FireSounds";
}; --Set values from existing settings
Mods = {
}; --Multiplies values of existing settings. NOTE: Must be number
Adds = {
nil_val = false;
}; --Add new settings
};
The first top one is a Condition name where you’ll need to give it a name when modules can use it to detect, it should match the actual name otherwise it reverts or errors, followed with the settings you add and set to.
["slow_bullet"] = {
Settings = {
Auto = true;
FireRate = 0.16;
FireSound = "slow_fire";
}; --Set values from existing settings
Mods = {
}; --Multiplies values of existing settings. NOTE: Must be number
Adds = {
nil_val = false;
}; --Add new settings
};
after making the Conditions tables, we’ll move to the Module that holds a function where we can make it trigger them, Conditionable function is inside Tool > Setting > ConditionableGunMods
where everything holds.
Scripting the actions
I recommend that you should have the knowledge of basic of scripting first to make a custom behavior, if you’re not already familiar, consider learning from Roblox’s official site here before you can make it.
inside ConditionableGunMods
after we set the mods, you’ll see them like this
local module = {
["Maxwell"] = function(Tool, Humanoid, Heat, MaxHeat, Mag, AmmoPerMag, Ammo, MaxAmmo, ShootCounts, CurrentFireRate)
return ShootCounts <= 1
end,
}
return table.isfrozen(module) and module or table.freeze(module)
we have to add all the mods function we created in the setting so that it recognizes the mods we created from the settings, if you’re trying to hook the mods from another tool, it won’t even work since it gets from the current tool, so the result should look like this after we’ve done setting it.
local module = {
["fast_bullet"] = function(Tool, Humanoid, Heat, MaxHeat, Mag, AmmoPerMag, Ammo, MaxAmmo, ShootCounts, CurrentFireRate)
return ShootCounts <= 1
end,
["slow_bullet"] = function(Tool, Humanoid, Heat, MaxHeat, Mag, AmmoPerMag, Ammo, MaxAmmo, ShootCounts, CurrentFireRate)
return ShootCounts <= 1
end,
}
return table.isfrozen(module) and module or table.freeze(module)
Now that tool recognizes the mod we created, we can now start scriptin in the way what we want, but the question is how the ####### do we know if it’s triggered???
well, from Parameters of course, we can make it trigger from detecting some values, if you just need to swap out the mods that does not involve with checking existing parameters then return it as a boolean so that Conditionable mods fire based on boolean we return with that stats but what about from parameters???
Simply it is from what we are checking, as long as it finds if x
== val
then returns true
from example it should pretty much look like this
Now that you’re finished, you can now make a custom functions and behavior without having to hurt GunClient and ProjectileHandler again!
custom behavior from a gun created in dvn: warfare
local CAS = game:GetService("UserInputService") --oops lol
local tool = script.Parent.Parent
local test = tool.GunClient.TestEvent
CAS.InputBegan:Connect(function(inputOBJ, GPE)
if GPE then
return
end
if inputOBJ.KeyCode == Enum.KeyCode.E and inputOBJ.UserInputState == Enum.UserInputState.Begin then
if tool.GunClient.mode.Value == "SLOW" then
tool.GunClient.mode.Value = "FAST"
end
test:Fire("onfire")
print(tool.GunClient.mode.Value, inputOBJ.KeyCode)
end
end)
CAS.InputEnded:Connect(function(inputOBJ, GPE)
if GPE then
return
end
if inputOBJ.KeyCode == Enum.KeyCode.E and inputOBJ.UserInputState == Enum.UserInputState.End then
if tool.GunClient.mode.Value == "FAST" then
tool.GunClient.mode.Value = "SLOW"
end
test:Fire("onstop")
print(tool.GunClient.mode.Value, inputOBJ.KeyCode)
end
end)
local module = {
["fast_bullet"] = function(Tool, Humanoid, Heat, MaxHeat, Mag, AmmoPerMag, Ammo, MaxAmmo, ShootCounts, CurrentFireRate)
if Ammo == 10 then
return true
elseif Ammo == 5 then
return false
end
end,
["slow_bullet"] = function(Tool, Humanoid, Heat, MaxHeat, Mag, AmmoPerMag, Ammo, MaxAmmo, ShootCounts, CurrentFireRate)
if Tool.GunClient.mode.Value == "SLOW" then
return true
elseif Tool.GunClient.mode.Value == "FAST" then
return false
end
end,
}
return table.isfrozen(module) and module or table.freeze(module)