I want to change the offset value of MouseLockController without forking it. In theory it is possible but I don’t think Roblox’s script is working as intended to; nullifying my method
I have succesfully changed the BoundKeys and CursorImage with a LocalScript, but not the CameraOffset
Here is my LocalScript:
local Players = game:GetService("Players")
-- Values
local KEYS = "LeftControl,RightControl"
local OFFSET = Vector3.new(5,5,0)
local IMAGE = "rbxassetid"
local MouseLockController = Players.LocalPlayer
.PlayerScripts
:WaitForChild("PlayerModule")
:WaitForChild("CameraModule")
:WaitForChild("MouseLockController")
local CameraUtils = require(Players.LocalPlayer
.PlayerScripts
:WaitForChild("PlayerModule")
:WaitForChild("CameraModule")
:WaitForChild("CameraUtils"))
local BoundKeys = MouseLockController:FindFirstChild("BoundKeys")
if BoundKeys then
BoundKeys.Value = KEYS
else
BoundKeys = Instance.new("StringValue")
BoundKeys.Name = "BoundKeys"
BoundKeys.Value = KEYS
BoundKeys.Parent = MouseLockController
end
local Offset = MouseLockController:FindFirstChild("CameraOffset")
if Offset then
Offset.Value = OFFSET
else
Offset = Instance.new("Vector3Value")
assert(Offset, "")
Offset.Name = "CameraOffset"
Offset.Value = OFFSET
Offset.Parent = MouseLockController
end
local Image = MouseLockController:FindFirstChild("CursorImage")
if Image then
Image.Value = IMAGE
else
Image = Instance.new("StringValue")
assert(Image, "")
Image.Name = "CursorImage"
Image.Value = IMAGE
Image.Parent = MouseLockController
CameraUtils.setMouseIconOverride(IMAGE)
end
I checked MouseLockController’s Module Script, it should return value or create a new instance if there’s none according to the script, but it did neither.
Section of MouseLockController’s GetMouseLockOffset:
function MouseLockController:GetMouseLockOffset()
if FFlagUserFixCameraOffsetJitter then
return CAMERA_OFFSET_DEFAULT
else
local offsetValueObj: Vector3Value = script:FindFirstChild("CameraOffset") :: Vector3Value
if offsetValueObj and offsetValueObj:IsA("Vector3Value") then
return offsetValueObj.Value
else
-- If CameraOffset object was found but not correct type, destroy
if offsetValueObj then
offsetValueObj:Destroy()
end
offsetValueObj = Instance.new("Vector3Value")
assert(offsetValueObj, "")
offsetValueObj.Name = "CameraOffset"
offsetValueObj.Value = Vector3.new(1.75,0,0) -- Legacy Default Value
offsetValueObj.Parent = script
end
if offsetValueObj and offsetValueObj.Value then
return offsetValueObj.Value
end
return Vector3.new(1.75,0,0)
end
end
I’m not sure if I’m just dumb since I just started to actually learn lua