How to lock camera

Hey everyone! It’s Happy! I just ran into a problem with my game! I want to know how to script a “lock camera” for a period of time, like an introduction!

(when you first enter this game, it will
ask you what team you want to be in)Example:

https://www.roblox.com/games/3082707367/RO-Wizard-BETA?refPageId=9807000b-3806-441c-8b7a-50312ded4c35
Thx

If you don’t understand, I’m trying to lock the camera so the player only sees what the camera is pointing at.

2 Likes

You could try and use CFrame for the camera.

1 Like

Change the camera type to Scriptable

2 Likes

This video will help you out with this problem.

Do you mean first-person mode? Just define the local player, then set the player’s cameramode to LockFirstPerson.

LocalScript (startergui or starterpack) :

wait(1)
local Player = game.Players.LocalPlayer
Player.CameraMode = "LockFirstPerson"

To accomplish what they do you have to set the CameraType to Scriptable and then set the CFrame to what you want it to point at.

Something like this is most likely what you are looking for:

local RunService = game:GetService("RunService")
local Workspace = game:GetService("Workspace")
local Players = game:GetService("Players")

local player = Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()

-- Make sure to change the part name to whatever you want it
-- to look at
local targetPart = Workspace:WaitForChild("Part")

-- Handles setting up the camera
local function SetupCamera()
	local cam = Workspace.CurrentCamera
	
	while (cam.CameraType ~= Enum.CameraType.Scriptable) do
		cam.CameraType = Enum.CameraType.Scriptable
		cam.CFrame = targetPart.CFrame - (targetPart.CFrame.LookVector * 5)
		RunService.RenderStepped:Wait()
	end
end

-- Setup the camera whenever the character is spawned
player.CharacterAdded:Connect(function()
	SetupCamera()
end)

-- Setup the camera when the player loads for the first time
SetupCamera()

Cutscene is probably what come to mind when you say that. Def try them.

This was so helpful! Thank you so much!