I am trying to activate shiftLock when the player clicks the mouse button but I keep getting this error: “attempt to call a nil value” when I try to require the cameraMoudle (line 2).
the LocalScript :
local plr = game.Players.LocalPlayer
local CameraModule = require(plr.PlayerScripts.PlayerModule.CameraModule).new()
local MouseLockController = CameraModule.activeMouseLockController
local shiftLockConn
function shiftLock(active) --Toggle shift lock function
shiftLockConn = game:GetService("RunService").RenderStepped:Connect(function()
MouseLockController:DoMouseLockSwitch(0, Enum.UserInputState.Begin) --enable the LockSwitch
end)
end
local function onInputBegan(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
shiftLock(true)
end
end
UserInputService.InputBegan:Connect(onInputBegan)
I tried to add wait Still not working, it’s not nil if I remove the new() and there was no error in this line, the error will be in “MouseLockController:DoMouseLockSwitch(0, Enum.UserInputState.Begin)” (line 7).