Med Written By 123nabilben123

Camera Manipulation Tutorial Created on: 20-12-2019

This tutorial will teach you about the Camera

Welcome to the Camera Tutorial! By 123nabilben123!

Welcome! In this tutorial I will teach you about the Camera. You will know how to manipulate it, and I'll even give a challenge about making your own cutscene!

This tutorial requires prior knowledge about a basic understanding of CFrame, and you know how to use a LocalScript.

Let's get started! First make a local script and put it wherever you want it. I'm gonna put mine in StarterGui. Get the LocalPlayer too. Your LocalScript should look like this:

local Player = game.Players.LocalPlayer

Alright we are gonna get the camera now! But, in everyone's computer, they have their own camera. The camera is located in the workspace.

If I grabbed the camera and you grabbed your own camera we have seperate cameras. You should not use a regular script for this because a roblox server doesn't play the game.

The camera's name is CurrentCamera, just to clear things up. To grab the camera we put:

local Player = game.Players.LocalPlayer
local Camera = game.Workspace.CurrentCamera

Now we have the camera! The Camera's rotation and position uses CFrame. So let's set its CFrame to something. Before that though, we need to set the Camera type property to scriptable.

The property is called "CameraType". It has a bunch of other things to set it to but we are going to use an enum that has all the values for the CameraType property and we are going to use the scriptable value. It's only use is for making your own scripted camera.

local Player = game.Players.LocalPlayer
local Camera = game.Workspace.CurrentCamera

Camera.CameraType = Enum.CameraType.Scriptable 

Great! Whenever you join the game your camera is going to act weird, that's because we've never set the CFrame property of it to something.

Let's do that, in the workspace, create a new part called "CameraPartA" and another part called "CameraPartB". Make sure to anchor them too and set CanCollide to false and make them fully transparent so it doesn't get in the way of the view.

These parts are going to be our vision when we set the CFrame of the camera to that.

Next, in your script reference them as variables:

local Player = game.Players.LocalPlayer
local Camera = game.Workspace.CurrentCamera

local CameraPartA = game.Workspace.CameraPartA
local CameraPartB = game.Workspace.CameraPartB

Camera.CameraType = Enum.CameraType.Scriptable

We are getting to the fun part, next in your script let's set the CFrame of the Camera to CameraPartA and then wait for 5 seconds and then set it to CameraPartB.

Make sure you do it after you set the CameraType property to scriptable.

local Player = game.Players.LocalPlayer
local Camera = game.Workspace.CurrentCamera

local CameraPartA = game.Workspace.CameraPartA
local CameraPartB = game.Workspace.CameraPartB

Camera.CameraType = Enum.CameraType.Scriptable

Camera.CFrame = CameraPartA.CFrame
wait(5)
Camera.CFrame = CameraPartB.CFrame

Now that you've tested it, your camera went and view those two parts, but the problem is that it can't set it back to the Character's head.

Whenever your walking normally in a game, your CameraType is Track and the Camera's CFrame is your Head. We also need to get the character for this to access the head part, we reset it back by:

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait() -- waiting for the character to load
local Camera = game.Workspace.CurrentCamera

local CameraPartA = game.Workspace.CameraPartA
local CameraPartB = game.Workspace.CameraPartB

Camera.CameraType = Enum.CameraType.Scriptable

Camera.CFrame = CameraPartA.CFrame
wait(5)
Camera.CFrame = CameraPartB.CFrame
wait(3) -- wait 3 seconds before switching

Camera.CameraType = Enum.CameraType.Track
Camera.CFrame = Character.Head.CFrame

You've done it! Go on the Roblox Wiki/Developer hub and search for Camera in the search bar or Camera Manipulation for more info!

If you understand CFrame basics and you know how to lerp, try making your own cutscene. The function for "lerping" the camera is :Interpolate(). It works just like the :Lerp function but you do not need to get the CFrame of the Camera, just the camera itself.

Interpolating the Camera would be like this:

local Camera = game.Workspace.CurrentCamera
Camera.CameraType = Enum.CameraType.Scriptable
Camera:Interpolate("INSERT PART CFRAME HERE", "INSERT NEXT PART CFRAME HERE",  1)

If you want to be fancy make a cintematic gui and make it fall down whenever the cutscene is playing using TweenService.

I made this tutorial since I didn't find any Camera tutorials here. The camera is one of the important aspects of a video game, it can really spice things up if you use it correctly.

That is the end of the tutorial, This is my first one and I'll be making more tutorials ranging from difficulty, I hope you learn something!

-123nabilben123

Med Written By 123nabilben123

See 123nabilben123's profile on Roblox

Discussion