Scriptable Camera not working upon CharacterAdded event

Greetings!
I’ve worked with camera before , more exactly i used tweens with the camera and it worked pretty well. However now it seems that i have a problem i cannot make it work the way i want.

I want that, once a player joins, the camera’s CFrame to be on a part while its focused on a different part.


--Checking For Character--
local playerservice = game:GetService("Players")
local player = playerservice.LocalPlayer


--Variables-- 
local CurrentCamera = game.Workspace.CurrentCamera
local MainIntro = script.Parent.Main
local Shade1 = script.Parent.Shade1
local Shade2 = script.Parent.Shade2

local TimeLoading = 25

player.CharacterAdded:Connect(function()
	print("Counting. Intro will begin soon!")
CurrentCamera.CameraType = Enum.CameraType.Scriptable
CurrentCamera.CFrame = game.Workspace.camera.CFrame
		wait(TimeLoading) --time before the loading screen yeets away
		MainIntro:TweenPosition(
	UDim2.new(1.1,0,-0.22,0),
	"InOut",
	"Quart",
	2,
	false,
	nil,
	false
	)
		Shade1:TweenPosition(
	UDim2.new(1.1,0,-0.22,0),
	"InOut",
	"Quart",
	2.5,
	false,
	nil,
	false
	)
		Shade2:TweenPosition(
	UDim2.new(1.1,0,-0.22,0),
	"InOut",
	"Quart",
	2.7,
	false,
	nil,
	false
	)
end)

I do not want it to tween, i just want it to be fixed on “camera” while looking at something else. I tried so far

CurrentCamera.Focus = game.Workspace.FocusPart.CFrame
CurrentCamera.CFrame = game.Workspace.camera.CFrame

and the versiun you see in the main script above. I placed and replaced them in and out of the function and got the same results, camera type is still custom and nothing happened to it.

Thanks for help! :heart:

Add a wait() before you set the camera type because when the character spawns, the camera type is set to Custom.
I believe you can also do something like this instead of the wait() to do it when it changes:

	workspace.CurrentCamera:GetPropertyChangedSignal("CameraType"):Wait()

That way it will wait until the camera type will change, but it might be a little more than the normal wait()

1 Like

So what you’re saying is if i add wait() before setting the camera type, everything will work?

1 Like

In my experience with using CharacterAdded for camera related endeavors it has always benefited me to use a sort of “sanity check loop” in order to make sure it is set:

repeat wait()
workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
until workspace.CurrentCamera.CameraType == Enum.CameraType.Scriptable
1 Like

Yes, because the camera is set to custom when the character spawns and there’s no need to repeat the command until it happens, because it will change after the camera is set to custom