Shiftlock Mauipulation (Q & E Keybinds)

  1. 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.

  2. Here’s video and my script
    robloxapp-20230617-1105411.wmv (1.6 MB)

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)
  1. 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.
2 Likes

The hell how you do upload video on forum and you could play it without downloading it?

I assume you’ve forked the whole CameraModule. By default, the module returns an empty table, so you’ll have to change it to cameraModuleObject.

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().

1 Like

Oh. Thanks but tested it out. But got error.

Error is
Players.Nuhnero.PlayerScripts.LocalScript:22: attempt to call missing method 'OnMouseLockToggled' of table - Client - LocalScript:22

Nvm. Got it. Forgot to add the return.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.