How to return camera back to normal after setting its cframe

so i made this and idk how to make it so after 3 seconds the camera is back to normal not at the parts cframe:

local RunService = game:GetService("RunService")

local camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable

local function updateCamera()
	local part2 = workspace:FindFirstChild("CameraPart")

	if part2 then
		camera.CFrame = part2.CFrame
	else
		warn("Part2 not found")
	end
end

RunService.RenderStepped:Connect(updateCamera)

You can try setting the CameraType back to Roblox Default (Enum.CameraType.Custom)

local RunService = game:GetService("RunService")

local camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable

local function updateCamera()
	local part2 = workspace:FindFirstChild("CameraPart")

	if part2 then
		camera.CFrame = part2.CFrame
	else
		warn("Part2 not found")
	end
end

--

RunService:BindToRenderStep("camUpdate", 1, updateCamera) --start renderstep func
task.wait(3)
RunService:UnbindFromRenderStep("camUpdate") --end renderstep func

camera.CameraType = Enum.CameraType.Custom -- return to player

I used RunService:BindToRenderStep() so that you can easily unbind the function when you don’t need the camera to follow the part anymore.

Roblox’s core scripts should bring the player’s camera back to the character after that.

1 Like

Should be pretty straight forward.

local RunService = game:GetService("RunService")
local camera = workspace.CurrentCamera

camera.CameraType = Enum.CameraType.Scriptable

local function updateCamera()
	local part2 = workspace:FindFirstChild("CameraPart")
	if part2 then
		camera.CFrame = part2.CFrame
	end
end

local connection = RunService.RenderStepped:Connect(updateCamera)

task.wait(3)
connection:Disconnect()
camera.CameraType = Enum.CameraType.Custom

both of them worked sadly i cant mark 2 solutions but ye they both work thx

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.