So, I’m trying to make an attachments system that modifies the stats by modifying the values of that in another module script, stored inside the attachments, etc. Adding the stats works but removing them doesn’t because the actual module is deleted once the attachment is removed.
I don’t want to reset the stats to default, Because it breaks other attachments… Anybody have any ideas on how i can save the module or maybe even the values inside the module to reference once the script is deleted? Or any less-complicated way to do this?
if #vm.Attachments.SightAtt:GetChildren() >0 then
for i, Attacher in ipairs(vm.Attachments.SightAtt:GetChildren()) do
if Attacher:IsA("Model") then
if Attacher:FindFirstChild("Accuracy") then
if Module.Sigt == false then
local modifier = require(Attacher.Accuracy)
Module.Sigt = true
Module.FieldOfViewIS = modifier.FieldOfViewIS
Module.SwitchScopeEnabled = modifier.SwitchScopeEnabled
Module.SecondScopeFOV = modifier.SecondScopeFOV
Module.ViewmodelRecoilInfluence = Module.ViewmodelRecoilInfluence + modifier.ViewmodelRecoilInfluence
Module.Spread = Module.Spread + modifier.Spread
Module.Accuracy = Module.Accuracy + modifier.Accuracy
Module.RecoilSpeed = Module.RecoilSpeed + modifier.RecoilSpeed
Module.RecoilRedution = Module.RecoilRedution + modifier.RecoilRedution
Module.AngleX_Min = Module.AngleX_Min + modifier.AngleX_Min
Module.AngleX_Max = Module.AngleX_Max + modifier.AngleX_Max
Module.AngleY_Min = Module.AngleY_Min + modifier.AngleY_Min
Module.AngleY_Max = Module.AngleY_Max + modifier.AngleY_Max
Module.AngleZ_Min = Module.AngleZ_Min + modifier.AngleZ_Min
Module.AngleZ_Max = Module.AngleZ_Max + modifier.AngleZ_Max
Module.SpreadRedutionIS = Module.SpreadRedutionIS + modifier.SpreadRedutionIS
Module.SpreadRedutionS = Module.SpreadRedutionS + modifier.SpreadRedutionS
Module.SniperEnabled = modifier.SniperEnabled
Module.FieldOfViewS = modifier.FieldOfViewS
print("yay")
end
end
end
end
else
for i, Attacher in ipairs(vm.Attachments.SightAtt:GetChildren()) do
if Attacher:IsA("Model") then
if Attacher:FindFirstChild("Accuracy") then
if Module.Sigt == true then
local modifier = require(Attacher.Accuracy)
Module.Sigt = false
Module.FieldOfViewIS = normSett.FieldOfViewIS
Module.SwitchScopeEnabled = normSett.SwitchScopeEnabled
Module.SecondScopeFOV = normSett.SecondScopeFOV
Module.ViewmodelRecoilInfluence = Module.ViewmodelRecoilInfluence - modifier.ViewmodelRecoilInfluence
Module.Spread = Module.Spread - modifier.Spread
Module.Accuracy = Module.Accuracy - modifier.Accuracy
Module.RecoilSpeed = Module.RecoilSpeed - modifier.RecoilSpeed
Module.RecoilRedution = Module.RecoilRedution - modifier.RecoilRedution
Module.AngleX_Min = Module.AngleX_Min - modifier.AngleX_Min
Module.AngleX_Max = Module.AngleX_Max - modifier.AngleX_Max
Module.AngleY_Min = Module.AngleY_Min - modifier.AngleY_Min
Module.AngleY_Max = Module.AngleY_Max - modifier.AngleY_Max
Module.AngleZ_Min = Module.AngleZ_Min - modifier.AngleZ_Min
Module.AngleZ_Max = Module.AngleZ_Max - modifier.AngleZ_Max
Module.SpreadRedutionIS = Module.SpreadRedutionIS - modifier.SpreadRedutionIS
Module.SpreadRedutionS = Module.SpreadRedutionS - modifier.SpreadRedutionS
Module.SniperEnabled = normSett.SniperEnabled
Module.FieldOfViewS = normSett.FieldOfViewS
print("nay")
end
end
end
end
end
Yes the code is extremely messy, Im trying to clean it up.