how to make a camera in roblox studio code example

Example: how to make a camera manipulation in roblox studio

local player = game.Players.LocalPlayer -- Checks the player it is in.
local character = player.Character or player.CharacterAdded:Wait() -- Finds the character but if its not found it waits for it.
local camera = workspace.CurrentCamera -- Finds the current camera from the workspace.
local RunService = game:GetService("RunService") -- When were going to step the simulation it will go very fast and will make gitters. So we add RunService. If you want it once you can remove this.
repeat
	camera.CameraType = Enum.CameraType.Scriptable -- Sets the camera to Scriptable.
    wait() -- Waits for a frame. (0.033 seconds.)
until camera.CameraType == Enum.CameraType.Scriptable -- Waits for the camera to be Scriptable.

--[[ You can have these 2 types if you want it to run forever or Run it once.
RunService.RenderStepped:Connect(function() -- Steps into each simulation.
	camera.CFrame = game.Workspace.CameraPart -- Rename camerapart to your camera.
end)
-- Or you can have this
camera.CFrame = game.Workspace.CameraPart -- Rename camerapart to your camera.
]]--

Tags:

Lua Example