Broken Camera Manipulation

This was working yesterday and since then its just stopped working, only changes I’ve added is terrain. :man_shrugging:

Broken code (a snippet from my star wars guns):

local PlayerModule = game.Players.LocalPlayer.PlayerScripts:WaitForChild("PlayerModule")
local cameras = require(PlayerModule):GetCameras()

function setCamera(max, actual, minimum, bool, x, y, z)
	local cameras = require(PlayerModule):GetCameras() -- To check if this has changed
	local CameraController = cameras.activeCameraController -- Is now apparently nil?
	Player.CameraMaxZoomDistance = max
	Player.CameraMinZoomDistance = actual
	Player.CameraMinZoomDistance = minimum
	CameraController:SetMouseLockOffset(Vector3.new(x, y, z))
	CameraController:SetIsMouseLocked(bool)
end

Any ideas? Documentation is basically non existent from my searches :slightly_frowning_face:

What is the “exploit” you mentioned in the title?

Apologies, the system apparently decided to name it that by default from my last post.

I don’t have a clue why it did that :man_facepalming:

1 Like

Try this:

local cameras = require(PlayerModule):GetCameras()

function setCamera(max, actual, minimum, bool, x, y, z)
	local cameras = require(PlayerModule):GetCameras() -- To check if this has changed
	local CameraController = cameras.activeCameraController -- Is now apparently nil?
	Player.CameraMaxZoomDistance = max
	Player.CameraMinZoomDistance = actual
	Player.CameraMinZoomDistance = minimum
    local lockOffsetVector = Vector3.new(x, y, z)
	CameraController:SetMouseLockOffset(lockOffsetVector)
	CameraController:SetIsMouseLocked(bool)
end

If that doesn’t work, make sure x, y, and z are not nil.

What have you done different… Am I missing something or did you just send me my code…

Also with no disrespect, please read the error before you comment hastily.

  • “attempt to index nil with ‘SetMouseLockOffset’” indicates that CameraController is nil however I can’t resolve why it might be.

https://developer.roblox.com/en-us/resources/release-notes-for-420

  • Fixed a bug where the PlayerModule API unintentionally exposed members of CameraModule.

life hits hard sometimes. :sob: