The script below is moving my camera, but it isn’t putting it exactly within the part that I want it to (camera1). All of the print statements are displayed in the output.
function changeCamera()
local camera = workspace.CurrentCamera
wait()
print('test')
camera.CameraType = Enum.CameraType.Fixed
print('test2')
camera.CFrame = game.Workspace.House.Cameras.Camera1.CFrame
print('test3')
end
game.ReplicatedStorage.ViewSecurity.OnClientEvent:Connect(changeCamera)
As you can see above, the camera is locking, but not directly within the part.
I believe that rather than using Enum.CameraType.Fixed, you should use Enum.CameraType.Scriptable for this purpose. So, instead of using:
function changeCamera()
local camera = workspace.CurrentCamera
wait()
print('test')
camera.CameraType = Enum.CameraType.Fixed
print('test2')
camera.CFrame = game.Workspace.House.Cameras.Camera1.CFrame
print('test3')
end
game.ReplicatedStorage.ViewSecurity.OnClientEvent:Connect(changeCamera)
You should use:
function changeCamera()
local camera = workspace.CurrentCamera
task.wait()
print('test')
camera.CameraType = Enum.CameraType.Scriptable
print('test2')
camera.CFrame = game.Workspace.House.Cameras.Camera1.CFrame
print('test3')
end
game.ReplicatedStorage.ViewSecurity.OnClientEvent:Connect(changeCamera)