Getting Camera CFrame from Enum.CameraType.Custom without setting camera to Enum.CameraType.Custom

So i have a script that Makes The Camera Rotate And when You press a button it Tweens the camera to
the CFrame of HumanoidRootPart
But i want The tween to Tween the camera to Enum.CameraType.Custom Cframe and i tried

workspace.Camera.CameraType = Enum.CameraType.Custom
local CameraCustomCFrame = workspace.Camera.CFrame
workspace.Camera.CameraType = Enum.CameraType.Scriptable

but id doesnt work so i have to do

workspace.Camera.CameraType = Enum.CameraType.Custom
wait(0)
local CameraCustomCFrame = workspace.Camera.CFrame
workspace.Camera.CameraType = Enum.CameraType.Scriptable

But that makes the camera glitch

Is your script is a local script?

local script and its in a screenGui

Does it like shake your camera or it rotates?

with the wait(0) added
It just Shakes and the works

Wait, it shakes and the script works?

hi @Chill_andTrill709 , I fixed the problem, can you try this and let me know if it works for you

local TweenService = game:GetService("TweenService")
local camera = workspace.CurrentCamera
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")

local targetCFrame = humanoidRootPart.CFrame

local tweenInfo = TweenInfo.new(
    1,
    Enum.EasingStyle.Quad,
    Enum.EasingDirection.Out,
    0,
    false,
    0
)

local tween = TweenService:Create(camera, tweenInfo, {CFrame = targetCFrame})

tween:Play()

:smile:

the script is

workspace.Camera.CameraType = Enum.CameraType.Scriptable

local TweenService = game:GetService("TweenService")
local rot = 0
local Menu = true

local CamPart =workspace:WaitForChild("CamPart")

script.Parent.Buttons.Play.Activated:Connect(function()
	
	
	workspace.Camera.CameraType = Enum.CameraType.Custom
	wait(0)
	local CF = workspace.Camera.CFrame	
	workspace.Camera.CameraType = Enum.CameraType.Scriptable
	workspace.Camera.CFrame = CamPart.CFrame
	Menu = false
	local Tweeninfo = TweenInfo.new(2,Enum.EasingStyle.Linear, Enum.EasingDirection.In,0,false)
	local Char = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
	local part = Char:WaitForChild("HumanoidRootPart")
	local Tween = TweenService:Create(workspace.Camera,Tweeninfo, {CFrame = CF})
	Tween:Play()
	wait(2)
	workspace.Camera.CameraType = Enum.CameraType.Custom
end)

repeat
	wait(0)
	rot+=0.5
	CamPart.Orientation = Vector3.new(-20,rot,0)
	workspace.Camera.CFrame = CamPart.CFrame
until Menu == false

robloxapp-20240330-1145080.wmv (1020.6 KB)
that is the vide you can hardly tell on it but it just flicers (because i set the camera type to custum and the back)and it works

Its located at the Folder > Videos > Roblox

To summarize i need to get the positon where the camera will be in camera type custom but when i get the cframe it flickers because
i set it to custom, get the cframe ,then set camera typa back to scriptable

this is good and i works but i want instead of tweening it to humanoid root part CFrame i want it to be the Cframe Camera will be in Enum.CameraType.Custom

you can make a while loop that sets the camera cframe to the targetCFrame

yea but i want it to tween to the CFrame the cameera will be in Custom type

I just want the CFrame the camera will be in Custom but without setting the type to custom because it flickers

i probbalby figgured it out i made a new camera made it rotate then when play is pressed i tween the new camera to the old one and the nset current camera back to the old one

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.