I'm trying to make a Lock-On Sequence but I can't seem to return the 'current camera' back to the character's humanoid. Would it have something to do with using 'run service' to execute my camera position? I've also tried manually trying to change the Camera's subject and type but it remains unchanged. At this point, I'm convinced it's an issue with 'run service' yet I don't know of another convenient method to manipulate the camera. Would there be another way to format this or is this the most optimal way and I need to run the code differently ( E.g Remote Events or etc.)?
--Services
local UIS = game:GetService("UserInputService")
local runService = game:GetService("RunService")
local Players = game:GetService("Players")
--Variables
local cam = workspace.CurrentCamera
local player = Players.LocalPlayer
local dummy = workspace.Dummy
local target = dummy.Head
local Check = 0
--Script
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.L then
if Check == 0 then
Check = 1
wait()
runService.RenderStepped:Connect(function()
cam.CameraType = Enum.CameraType.Scriptable
cam.CameraSubject = target
local character = player.Character
if character and character.UpperTorso and character.Head then
local torso = character.UpperTorso
local head = character.Head
local ZPosition = Vector3.new(head.CFrame.X, head.CFrame.Y + 2, head.CFrame.Z)
cam.CFrame = CFrame.new(ZPosition, target.Position) * CFrame.new(2, 0, 8)
cam.Focus = CFrame.new(target.Position)
end
end)
elseif Check == 1 then
Check = 0
print("Off")
workspace.CurrentCamera.CameraSubject = player.Character.Humanoid
workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
end
end
end)

2 comments
wouldn't it just be an infinite loop with RenderStepped? You can change the camera subject back to the humanoid but it will just go back to your custom camera manipulation
That's what I thought, would there be a more efficient way to make my custom camera manipulation or is there a way to break the loop so I could re - assign the camera subject.