What do you want to achieve? I want to shift lock update when I change my offset of shift lock. But the problem is when I change offset with my shift lock. It didn’t update. I need to get disenable, then enable my shift lock to change. I want it change when I click the keybind and other problem is PlayerModule or CameraModule is too complicated for me.
local player = game:GetService("Players").LocalPlayer
local UIS = game:GetService("UserInputService")
local PlayerScripts = player:WaitForChild("PlayerScripts")
local PlayerModule = PlayerScripts:WaitForChild("PlayerModule")
local CameraModule = PlayerModule:WaitForChild("CameraModule")
local MouseLockController = CameraModule:WaitForChild("MouseLockController")
local LockshiftOffest = MouseLockController.CameraOffset
UIS.InputBegan:Connect(function(input, gpe)
if input.KeyCode == Enum.KeyCode.Q and not gpe then
print("Clicked Q")
LockshiftOffest.Value = Vector3.new(-1.75, 0 ,0)
end
end)
UIS.InputBegan:Connect(function(input, gpe)
if input.KeyCode == Enum.KeyCode.E and not gpe then
print("Clicked E")
LockshiftOffest.Value = Vector3.new(1.75, 0 ,0)
end
end)
What solutions have you tried so far?
I’ve tried to looking on this forum or api and I only could find is smoothshiftlock but it’s not what I want.
There’s a function at the end called :OnMouseLockToggled(). The script calls it whenever mouse lock is toggled, and only then takes the new offset value. It doesn’t listen for changes, so you’ll have to call it again.
The following should work.
local player = game:GetService("Players").LocalPlayer
local UIS = game:GetService("UserInputService")
local PlayerScripts = player:WaitForChild("PlayerScripts")
local PlayerModule = PlayerScripts:WaitForChild("PlayerModule")
local cameraModulePath = PlayerModule:WaitForChild("CameraModule")
local CameraModule = require(cameraModulePath)
local MouseLockController = cameraModulePath:WaitForChild("MouseLockController")
local LockshiftOffest = MouseLockController:WaitForChild("CameraOffset")
local shoulder = "Right" -- if initial value is (1.75, 0, 0)
UIS.InputBegan:Connect(function(input, gpe)
if gpe then return; end
if input.KeyCode == Enum.KeyCode.Q and shoulder ~= "Left" then
print("Clicked Q")
shoulder = "Left"
LockshiftOffest.Value = Vector3.new(-1.75, 0 ,0)
CameraModule:OnMouseLockToggled()
elseif input.KeyCode == Enum.KeyCode.E and shoulder ~= "Right" then
print("Clicked E")
shoulder = "Right"
LockshiftOffest.Value = Vector3.new(1.75, 0, 0)
CameraModule:OnMouseLockToggled()
end
end)
PS: Camera module will also be accessible via PlayerModule:GetCameras().