General Practice
Use :WaitForChild() to make sure that something exists before using or changing it.
If you do not set the focus of the CurrentCamera's CFrame using CFrame.new(position1, position2) then you need to use the CameraSubject property of the Current Camera to set its focus.
Issues
You need to place the LocalScript inside an area that is directly used by the Client (such as the StarterGui) in order for it to run correctly (Workspace is NOT one of these places)
In order to get the ClickDetector you will have to manually input its location, so for my example below, the ClickDetector is in a part named "ClickPart" which is in the Workspace, and upon being clicked, will cut to the view of the part "Cam1" which is also in the Workspace.
Revised Local Script under StarterGui
local camera = workspace.CurrentCamera
local campart = workspace:WaitForChild("Cam1")
local click = workspace:WaitForChild("ClickPart"):WaitForChild("ClickDetector")
click.MouseClick:Connect(function()
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = campart.CFrame
camera.CameraSubject = campart
end)
6 comments
you forgot the e at the end of Scriptable on line 5
my bad, but the script still isnt working
probably because you put a local script in the workspace where they do not run. https://developer.roblox.com/api-reference/class/LocalScript
dosent work if its a local or a global script
You're missing CameraSubject.
move the local script to a place it can run. I did not say to chenage it to a server script. The server does not have access to the players camera.