You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
– Fix OOP module.
- What is the issue? Include screenshots / videos if possible!
– OOP is created without attributes like: InputConnections, VECTOR_Shake and others.
My module:
-------------------------
-- SERVICES --
-------------------------
local ReplicatedStorage = game:FindService('ReplicatedStorage')
local UserInputService = game:FindService('UserInputService')
local TweenService = game:FindService('TweenService')
local RunService = game:FindService('RunService')
local Players = game:FindService('Players')
-------------------------
-- TYPES --
-------------------------
type State = 'Idle' | 'IdleCrouch' | 'Walk' | 'Sprint' | 'Crouch' | 'Fall'
-------------------------
-- VARIABLES --
-------------------------
local LocalPlayer = Players.LocalPlayer
local CurrentCamera = workspace.CurrentCamera
local Modules = ReplicatedStorage:WaitForChild('Modules')
local Utilities = Modules:WaitForChild('Utilities')
local CAMERA_HANDLER = {}
CAMERA_HANDLER.__index = CAMERA_HANDLER
-------------------------
-- DEPENDENCIES --
-------------------------
local SPRING = require(Utilities:WaitForChild('Spring'))
-------------------------
-- PRIVATE FUNCTIONS --
-------------------------
-------------------------
-- PUBLIC FUNCTIONS --
-------------------------
function CAMERA_HANDLER.new()
local self = setmetatable({}, CAMERA_HANDLER)
self.VECTOR_Shake = Instance.new('Vector3Value')
self.CameraTilt = Instance.new('NumberValue')
self.CameraTilt.Name = 'CameraTilt'
self.FallTilt = Instance.new('NumberValue')
self.FallTilt.Name = 'FallTilt'
self.CrouchTilt = Instance.new('NumberValue')
self.CrouchTilt.Name = 'CrouchTilt'
self.FALL_Updated = 0
self.PREVIOUS_DeltaTime = 0.333
self.MISSING_Updated = os.clock()
self.MainSpring = SPRING.new(Vector3.zero)
self.MainSpring:__newindex('Damper', 0.5)
self.MainSpring:__newindex('Speed', 8)
self.BobbingSpring = SPRING.new(Vector3.zero)
self.BobbingSpring:__newindex('Damper', 0.9)
self.BobbingSpring:__newindex('Speed', 10)
self.AX, self.AY, self.AZ = 0, 0, 0
self.AX_T, self.AY_T, self.AZ_T = 0, 0, 0
self.CameraLocked, self.CameraLockedOffset = false, {0, 0}
self.CameraSmoothness, self.CameraSensitivity = 40, 0.3
self.MouseLocked = false
self.InputConnections = {}
return self
end
function CAMERA_HANDLER:Enable()
self.InputConnections[#self.InputConnections + 1] = UserInputService.InputBegan:Connect(function(InputObject : InputObject, ProcessedEvent : boolean) : () -- Here error: self.InputConnections is nil.
if ProcessedEvent then return end
if InputObject.UserInputType == Enum.UserInputType.Keyboard and InputObject.KeyCode == Enum.KeyCode.L then
self.MouseLocked = not self.MouseLocked
end
end)
-- || Other code.
end
function CAMERA_HANDLER:Disable()
for Index, Connection : RBXScriptConnection in self.InputConnections do
Connection:Disconnect()
self.InputConnections[Index] = nil
end
self.InputConnections = {}
end
-------------------------
-- END OF CODE --
-------------------------
return CAMERA_HANDLER