I have a view model controller and a gun controller, and I want to create a swaying and bobbing effect. The issue is that when ever I add a spring object into my view model controllers self table, it sets the spring objects self to nil, along with every variable inside its self table. The only solution I have had is using math to create the swaying and bobbing.
Here is my self table in my view model controller:
local self = {
gun = gun,
handle = gun:WaitForChild("Handle"),
viewmodel = viewmodel,
viewmodelGun = viewmodel:WaitForChild("Gun").Value,
connections = {},
toolConnections = {},
enabled = false,
animations = {},
showTools = false,
toolInstances = {},
fxController = FXController.new(viewmodel),
stride = 0,
bobbing = 0,
swaying = 0,
offset = 0,
swayCF = CFrame.new(), --ignore this
currentSwayAMT = .8, --ignore this
lastCameraCF = CFrame.new(), --ignore this
aiming = false,
aimingLerpValue = Instance.new("NumberValue"),
aimInTween = nil,
aimOutTween = nil,
swaySpring = SpringModule.new()
}
Any help is appreciated.