Module values getting switched up

  1. I have an issue whenever I try to get a number value from a module to another that number will always be changed then how it was in the other module. That meaning lets say i have 2 modules and i put 500 in one. On the other module i require it and print it on the other module it’ll print something different then 500.

  2. Im trying to get a module projectile penetration power by another module and it never comes out the same as i put it.

  3. I thought about putting it manually but I rather want it in a module since it will be easier.

Here is the ProjectileModule:

function CanPierce(cast, result, velocity, cosmeticBullet)	local calibermodule = require(ReplicatedStorage:WaitForChild("Calibers"))	local imp = cast.UserData.imp	local trueCaliber = imp.config.ammo.Caliber or ""	local caliberData = calibermodule[trueCaliber]	if not caliberData then	return false	end	local PenetrationPowerFromModule = caliberData.PenetrationPower or 0	local hitPart = result.Instance	if not hitPart then	return false	end	if hitPart.Name == "Handle"	or hitPart.Name == "HumanoidRootPart"	or hitPart.Parent:IsA("Accessory")	or hitPart.Name == "handle"	or hitPart.Parent:IsA("Accoutrement") then	return true	end	local storedPower = cast.UserData.remainingPower	if not storedPower then	storedPower = PenetrationPowerFromModule	cast.UserData.remainingPower = storedPower	end	print(PenetrationPowerFromModule)	local Penetration = require(ReplicatedStorage.gunres.Modules:WaitForChild("Penetration"))	local ResistanceTable = Penetration.Resistance	local characterModel = hitPart:FindFirstAncestorOfClass("Model")	local hasHumanoid = characterModel and characterModel:FindFirstChildOfClass("Humanoid")	local resistanceKey	if hasHumanoid then	resistanceKey = "Humanoid"	else	resistanceKey = ResistanceTable[hitPart.Name] and hitPart.Name or tostring(result.Material):gsub("Enum%.Material%.", "")	end	local baseResistance = ResistanceTable[resistanceKey] or 9999	local width = math.min(hitPart.Size.X, hitPart.Size.Y)	local widthMultiplier = math.clamp((width / 2), 0.5, 2)	local resistance = baseResistance * widthMultiplier	if storedPower >= resistance then	storedPower -= resistance	cast.UserData.remainingPower = storedPower	cast:SetVelocity(velocity * (imp.config.ammo.ballistics and imp.config.ammo.ballistics.speedMult or 1) * 0.5)	return true	else	return false	end end 

then the caliberModule:

return {	[".22 LR"] = {	-- Damage = 15	Velocity = 1178,	AirFriction = -0.0015,	PenetrationPower = 297.85,	Spread = 2.0	},	[".380 ACP"] = {	-- Damage = 27	Velocity = 928,	AirFriction = -0.0016,	PenetrationPower = 280,	Spread = 2.5	},	["9x19mm"] = {	-- Damage = 32	Velocity = 1320,	AirFriction = -0.003,	PenetrationPower = 294,	Spread = 2.0	},	[".45 ACP"] = {	-- Damage = 32	Velocity = 928,	AirFriction = -0.00145,	PenetrationPower = 218.4,	Spread = 2.8	},	[".357 Magnum"] = {	-- Damage = 50	Velocity = 1464,	AirFriction = -0.0014,	PenetrationPower = 396,	Spread = 2.3	},	["5.45x39mm"] = {	-- Damage = 80	Velocity = 3213,	AirFriction = -0.00027,	PenetrationPower = 554.4,	Spread = 1.0	},	["5.56x45mm"] = {	-- Damage = 80	Velocity = 3356,	AirFriction = -0.00105,	PenetrationPower = 765,	Spread = 0.9	},	["7.62x39mm"] = {	-- Damage = 80	Velocity = 2570,	AirFriction = -0.00143,	PenetrationPower = 810,	Spread = 1.2	},	["9x39mm"] = {	-- Damage = 55	Velocity = 1000,	AirFriction = -0.00055,	PenetrationPower = 450,	Spread = 1.4	},	[".308 Winchester"] = {	-- Damage = 110	Velocity = 2927,	AirFriction = -0.00085,	PenetrationPower = 885.5,	Spread = 0.8	},	["7.62x54mmR"] = {	-- Damage = 110	Velocity = 2963,	AirFriction = -0.0008,	PenetrationPower = 800.7,	Spread = 0.85	},	["12ga 00 Buckshot"] = {	-- Damage = 95	Velocity = 1428,	AirFriction = -0.00675,	PenetrationPower = 212.5,	Spread = 6.0	},	["12ga Rifled Slug"] = {	-- Damage = 80	Velocity = 1428,	AirFriction = -0.006,	PenetrationPower = 475,	Spread = 2.5	},	["12ga Rubber Slug"] = {	-- Damage = 15	Velocity = 500,	AirFriction = -0.005,	PenetrationPower = 7.5,	Spread = 3.5	} } 
2 Likes

Can i ask why your calling the
local calibermodule = require(ReplicatedStorage:WaitForChild(“Calibers”))
Every time the function is ran/called ?

1 Like

Thought this would fix the process by having direct access to the module.