in the StarterPlayer, you’re able to do things such as disable shift lock. but when i try to change the DevCameraOcclusionMode to “Invisicam”, it works, but only in studio. when i try to change this via a script, i get these errors:
"Insufficent permissions to set DevCameraOcclusionMode - Studio "
“The current thread cannot set 'DevCameraOcclusionMode' (lacking capability RobloxScript)”
local services = {
Players = game:GetService("Players");
RunService = game:GetService("RunService");
}
local client = services.Players.LocalPlayer
local camera = workspace.CurrentCamera
-- client.DevCameraOcclusionMode = Enum.DevCameraOcclusionMode.Invisicam
local camera_depth = 62
local height_offset = 2
local field_of_view = 15
function ray_plane(plane_point, plane_normal, origin, direction)
return -((origin - plane_point):Dot(plane_normal)) / (direction:Dot(plane_normal))
end
function create_body_gyro(parent)
local body_gyro = Instance.new("BodyGyro")
body_gyro.Parent = parent
body_gyro.D = 40
body_gyro.P = 10000
body_gyro.MaxTorque = Vector3.new(4000000, 4000000, 4000000)
print("gyro created, delicious!")
return body_gyro
end
function setup_camera(character)
local head = character:WaitForChild("Head")
local root = character:WaitForChild("HumanoidRootPart")
local plr_pos = root.Position + Vector3.yAxis * height_offset
local cam_pos = plr_pos + Vector3.one * camera_depth
camera.CFrame = CFrame.lookAt(cam_pos, plr_pos)
return head
end
function update_body_gyro(body_gyro, head, target_cframe)
if body_gyro then
body_gyro.CFrame = body_gyro.CFrame:lerp(target_cframe, 0.15)
end
end
function setup()
local character = client.Character or client.CharacterAdded:Wait()
local mouse = client:GetMouse()
local ray = camera:ScreenPointToRay(mouse.X, mouse.Y)
local t = ray_plane(character.Head.Position, Vector3.new(0, 1, 0), ray.Origin, ray.Direction)
local head = setup_camera(character)
services.SoundService:SetListener(Enum.ListenerType.ObjectCFrame, head)
local body_gyro = head:FindFirstChildOfClass("BodyGyro") or create_body_gyro(head)
local plane_intersection_point = (ray.Direction * t) + ray.Origin
local target_cframe = CFrame.lookAt(head.Position, plane_intersection_point)
update_body_gyro(body_gyro, head, target_cframe)
end
camera.FieldOfView = field_of_view
camera.CameraType = Enum.CameraType.Scriptable
services.RunService.RenderStepped:Connect(setup)
After a quick read of the documentation for this mode, I stumbled upon this: Defines how the default camera scripts handle objects between the camera and the camera subject. Set by StarterPlayer.DevCameraOcclusionMode and can’t be changed for individual players.
As it states, it cannot be changed for each individual player, which would be the most likely reason for this issue that is occurring for you.
I’ve done some digging. From what I’ve seen the DevCameraOcclusionMode is only for Studio and does not work within the live game environment. From what I’ve read here it can only be changed from a plugin or the command execution bar built into studio.
I had asked ROBLOX’s AI Assistant for insight which they provided you can use other alternative methods such as:
Raycasting: You can use raycasting to detect if there are any objects obstructing the camera’s view. By casting a ray from the camera’s position towards the player’s character, you can check if the ray intersects with any objects. If it does, you can adjust the camera’s position or field of view to avoid the obstruction.
Custom Camera Scripts: Instead of relying on the default camera scripts provided by Roblox, you can create your own custom camera scripts. This gives you more control over the camera’s behavior and allows you to implement features like camera occlusion or visibility checks. You can find tutorials and resources online that can help you create custom camera scripts.
Camera Manipulation: Another approach is to manipulate the camera’s position or field of view based on the player’s actions or the game’s mechanics. For example, you can zoom in or out when the player enters certain areas or interacts with specific objects. This can help ensure that the camera provides a clear view of the gameplay without being obstructed.