Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why isn't my camera manipulation script working?

this is my script:

print('Scipt has started')

local cam = workspace.CurrentCamera
local player = game.Players.LocalPlayer
local FocusPart = game.Workspace.FocusPoint
local EndPart = game.Workspace.EndPart


cam.CameraType = "Scriptable"
local pos = Vector3.new(85, 4, -13)
local lookAt = Vector3.new(80.75, 5.25, -14.25)
local cameraCFrame = CFrame.new(pos, lookAt)
cam.CFrame = cameraCFrame

it is a local script in starter player scripts and its for manipulating the camera to be to "pos" and then look at "lookAt" please help.

4 comments

0

does the camera type to "Scriptable"?

0

yes

0

you did local FocusPart = game.Workspace.FocusPoint, but there's no part in workspace named FocusPoint

0

therefore, you need to make sure there's a part named FocusPoint directly in workspace and do game.Workspace:WaitForChild("FocusPoint")

1 answer

✓ Accepted answer

The problem is the code runs sooner than when the default camera scripts load.. therefore, when they load, they overwrite any changes you made to the camera.. so to combat this, you need to add a wait statement on top of the script to allow the default camera scripts to load first..

wait(4)
print('Scipt has started')
local cam = workspace.CurrentCamera
local player = game.Players.LocalPlayer
local FocusPart = game.Workspace.FocusPoint
local EndPart = game.Workspace.EndPart


cam.CameraType = "Scriptable"
local pos = Vector3.new(85, 4, -13)
local lookAt = Vector3.new(80.75, 5.25, -14.25)
local cameraCFrame = CFrame.new(pos, lookAt)
cam.CFrame = cameraCFrame

This discussion is preserved as it was. New answers, comments, and votes are closed.