How do i change the shiftlockoffset via scripts?

hey guys i am creating a script and i want to change the shiftlockoffset so when this happends:

image

the offset should turn to Vector3.new(70, 40, 0)

what i have tried, i have tried changing the modulescript like trying to detect a boolvalue in the players char and then if its true the offset changes to this Vector3.new(70, 40, 0) but then i realized it doesnt check evry second if the value is true so thats where i am stuck at, i have also tried it trough scripts but it didnt seem to work so…

i need some help on this :slight_smile: evrything is appreciated!!

2 Likes

Check out this post, I believe it has the answer you’re looking for.

4 Likes

this didnt seem to work since its an old cameramodule script. do you know any other way?

Maybe this helps.

1 Like

I’m not sure if it’s more recent than the post you linked but you can create a Vector3Value inside of PlayerScripts.PlayerModule.CameraModule.MouseLockController called “CameraOffset” and it should allow you to configure the offset

image

However it still requires some manual intervention so you will still need to fork the PlayerModule so it actually updates if the player is currently shift locked.

Here are the list of changes:

1: PlayerModule.CameraModule @ line 132, adds self.activeMouseLockController.cameraModule = self so the mouseLockController can access the CameraModule object

2: PlayerModule.CameraModule @ line 579, replaces return {} with return cameraModuleObject

3: PlayerModule.CameraModule.MouseLockController @ line 76 adds self:GetMouseLockOffset(). This will create the relevant Vector3Value

4: PlayerModule.CameraModule.MouseLockController @ line 78 adds a connection to update the mouse lock offset.

You can now modify the CameraOffset value and it should update as expected on change. It’s a much neater implementation so try it out and let me know if it suits your needs. The PlayerModule is found in StarterPlayer.StarterPlayerScripts

mouseLockOffset.rbxl (181.2 KB)

3 Likes

it worked, ty :slight_smile:


local function changeFOV(fov, cameraOffset, shiftlockoffset)
	workspace.CurrentCamera.FieldOfView = fov

	local humanoid = game.Players.LocalPlayer.Character:FindFirstChildOfClass("Humanoid")
	if humanoid then
		humanoid.CameraOffset = cameraOffset
	end
	local vectroval = game.Players.LocalPlayer.PlayerScripts.PlayerModule.CameraModule.MouseLockController.CameraOffset
	vectroval.Value = shiftlockoffset
end

us.InputBegan:Connect(function(Input)
	if Input.KeyCode == Enum.KeyCode.E then
		if script.Susanoo.Value == true then
			if script.SusanooStage.Value == 4 and script.Use.Value == false then
				changeFOV(120, Vector3.new(0, -40, 15), Vector3.new(70, 40, 0))
				
				
			elseif script.SusanooStage.Value == 4 and script.Use.Value == true then
				changeFOV(70, Vector3.new(0, 0, 0), Vector3.new(1.75, 0, 0))
			end
			script.Susanoore:FireServer()
		end
	end
end)

i found out what i did wrong!!!

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