Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 3 years ago
Edited 3 years ago

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
0
Try setting it on the server 0hsa 193 — 3y
0
workspace.CurrentCamera can only be accessed on client-side scripts provit_026 2 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

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)
0
Thanks a lot! Setting CameraType in remote event callback actually helped! provit_026 2 — 3y
Ad

Answer this question