Camera script stops working on reset

i made this script for a camera system that sets you camera to a part when you press a button but if the person is using the camera then resets there character it brakes please can some one help fix this

here is the script

local myCamera = workspace.CurrentCamera – Reference users camera object
local cameraPart = workspace.UniverseLightingCameraSystem.CameraPart

script.Parent.MouseButton1Down:Connect(function()
if script.Parent.Value.Value == 0 then
myCamera.CameraType = Enum.CameraType.Scriptable

	myCamera.CFrame = cameraPart.CFrame * CFrame.Angles(0,0,0) 
	
	script.Parent.Value.Value = 1
else
	myCamera.CameraType = Enum.CameraType.Custom
	
	script.Parent.Value.Value = 0
end

end)

If anyone wants a video showing what happens i can give that to you if it helps

you dont need to use CFrame.Angles for the Setting myCamera’s CFrame.
You can Delete The

* CFrame.Angles(0,0,0)

1 Like

Is that good enough for you to find the problem?

I recommend disable character reset while camera is locked

local myCamera = workspace.CurrentCamera – Reference users camera object
local cameraPart = workspace.UniverseLightingCameraSystem.CameraPart

script.Parent.MouseButton1Down:Connect(function()
  if script.Parent.Value.Value == 0 then
    game:GetService("StarterGui"):SetCore("ResetButtonCallback", false)
    myCamera.CameraType = Enum.CameraType.Scriptable
    myCamera.CFrame = cameraPart.CFrame * CFrame.Angles(0,0,0) 
    script.Parent.Value.Value = 1
  else
    game:GetService("StarterGui"):SetCore("ResetButtonCallback", true)
    myCamera.CameraType = Enum.CameraType.Custom
    script.Parent.Value.Value = 0
end
1 Like