Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why doesn't Enum.CameraType.Scriptable lock camera?

Alright, so what I'm trying to do is lock camera and move it only when server fires you with CFrame. Script is obviously client-sided.

My code so far:

local camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable -- does not lock the camera

workspace.MoveCamera.OnClientEvent:Connect(function(cframe)
	camera.CFrame = cframe -- that moves the camera, but doesn't change zoom and player still can move camera afterwards
)

Problems are written in comments, but I'll repeat

  1. Enum.CameraType.Scriptable does not lock the camera
  2. Setting CFrame moves camera, but doesn't affect zoom and player still can move camera after that

2 comments

0

Try setting it on the server

0

workspace.CurrentCamera can only be accessed on client-side scripts

1 answer

✓ Accepted answer

You need to set the CameraType property to "Scriptable", and then immediately set its CFrame.

Example:

camera = workspace.CurrentCamera

camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = CFrame.new(0,0,0)

You can unlock it by setting its CameraType to "Custom".

camera.CameraType = Enum.CameraType.Custom

If you want to fire the client, you can use this solution:

RemoteEvent.OnClientEvent:Connect(function()
	camera.CameraType = Enum.CameraType.Scriptable
	camera.CFrame = CFrame.new(0, 0, 0)
end)

1 comment

0

Thanks a lot! Setting CameraType in remote event callback actually helped!

This discussion is preserved as it was. New answers, comments, and votes are closed.