Unlocking after screen is locked

  1. What do you want to achieve? Keep it simple and clear!
    unlocking after screen is locked
  2. What is the issue? Include screenshots / videos if possible!
    camera does not unlock

script :
local re = game.ReplicatedStorage.RTom
script.Parent.MouseButton1Click:Connect(function()
re:FireServer(6321108591)
local camera = game.Workspace.CurrentCamera – finds the camera
local Run = game:GetService(“RunService”)
local part = workspace.CamDum – name of my camera part
camera.CameraType = Enum.CameraType.Scriptable
camera.CameraSubject = part

    	local function OnChanged()
    		camera.CFrame = part.CFrame
    		wait()
    	end
    	Run.RenderStepped:Connect(OnChanged) -- checks for when part moves
    	wait(1.26)
    	local Camera = game.Workspace.CurrentCamera
    	Camera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
    	end)
  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

yes i found this code but it doesn’t work

You’ve gotta set the CameraType to Enum.CameraType.Custom. (When unlocking the camera)

no change

`local re = game.ReplicatedStorage.RTom
script.Parent.MouseButton1Click:Connect(function()
re:FireServer(6321108591)
local camera = game.Workspace.CurrentCamera – finds the camera
local Run = game:GetService(“RunService”)
local part = workspace.CamDum – name of my camera part
camera.CameraType = Enum.CameraType.Scriptable
camera.CameraSubject = part

local function OnChanged()
	camera.CFrame = part.CFrame
	wait()
end
Run.RenderStepped:Connect(OnChanged) -- checks for when part moves
wait(1.26)
local Camera = game.Workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Custom
wait()
Camera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
end)`