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)
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.
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