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:
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()