How to make invisicam work with a scripted camera?

Okay, so I’m working on a top-down game using a scripted camera and I’m getting the strangest results trying to incorporate invisicam. So far, it has either been that it doesn’t work at all or it works at the cost of breaking the rest of the scripted camera.

I’ve tried:

  • Using the invisicam sample code in StarterPlayerScripts
  • Using it in StarterCharacterScripts
  • Incorporating it into the CameraController script I’m using.
  • I have already set it to invisicam manually.
  • If I put it in the CameraHandler before making the camera scriptable, it works but the scriptable camera does not.
  • If I put it in the CameraHandler after setting the camera to scriptable, the camera breaks and no longer moves at all.
  • If I place it anywhere besides the CameraHandler script, it simply doesn’t do anything.
  • Setting it to invisicam manually and not attempting to script it, the invisicam doesn’t work.
  • I’ve looked through the forums, the developer hub, and even YouTube. So far I haven’t found a workable solution for this.

Here’s the CameraHandler script. It is a local script in StarterCharacterScripts
This is the only version where Invisicam worked, but it breaks the rest of the script.

local player = game.Players.LocalPlayer

player.DevCameraOcclusionMode = Enum.DevCameraOcclusionMode.Invisicam

local cam = workspace.CurrentCamera
local char = script.Parent
local hrp = char:WaitForChild("HumanoidRootPart")

cam.CameraType = Enum.CameraType.Scriptable

local cameraPart = Instance.new("Part")
cameraPart.Transparency = 1
cameraPart.CanCollide = false
cameraPart.Parent = workspace

cameraPart.CFrame = CFrame.new(hrp.Position + Vector3.new(-20, 30, 0), hrp.Position)

local bp = Instance.new("BodyPosition")
bp.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
bp.Parent = cameraPart

game:GetService("RunService").RenderStepped:Connect(function()
	bp.Position = hrp.Position + Vector3.new(-20, 30, 0)
	cam.CFrame = cameraPart.CFrame
end)

Note: By default, DevCameraOcclusionMode was set to Zoom.
If you run this script just as it is and you have not changed it to Invisicam
Even though the script sets it to Invisicam
It will function by Zooming

7 Likes