Tween between camera subjects?

Im trying to tween between CFrame camerasubjects is it even possible? Ive tried to create a camera and assign the camerasubject to it, but because ROBLOX, the best developing engine, multiple cameras DONT WORK?! Script:

THIS IS THE CLONED CAMERA FUNCTION THAT DOESNT WORK BECAUSE POSITION DOESNT GET UPDATED >:(

3 Likes

you are one bad boy

you can’t have multiple cameras at once, like duh

you can change the current camera’s position, not create a new one, that will implode your code

1 Like

of course not working multiple cameras, I just need the position, which doesnt UPDATE.
“you can change the current camera’s position, not create a new one, that will implode your code” YEAH THATS WHAT I AM ASKING FOR, HOW TO GET THE CFRAME IF I CANT USE POSITION OF THE CAMERA

I maybe figured it out gimme sec

1 Like

wdym

local Camera = workspace.CurrentCamera
local CamCframe = Camera.CFrame

or try setting the camera type to something other than custom or scriptable.

1 Like

I change subject from humanoid to head back to humanoid and I want to smoothly change it from the head back to the humanoid, so I set the camera to scriptable and I want to tween the camera cframe to the humanoid subject cframe. Its hard to explain

2 Likes

Nah I give up I dont have time to waste like this

1 Like

why not just tween the camera to a part, instead of another camera??

1 Like

And what would be the parts cframe?

1 Like

whatever you want it to be ._.

“I change subject from humanoid to head back to humanoid and I want to smoothly change it from the head back to the humanoid, so I set the camera to scriptable and I want to tween the camera cframe to the humanoid subject cframe. Its hard to explain”

you need to use .RenderStepped to actively update the camera

additionally try not setting the camera type to scriptable and see if that changes anything

i made this script to move the camera smoothly between camera subjects

task.wait(1)
local RS = game:GetService("RunService")
local cam = workspace.CurrentCamera
local timeToTween = 1 

local function tweenCam(newSubject)
	local oldPart
	local newPart
	if cam.CameraSubject:IsA("Humanoid") then
		oldPart = cam.CameraSubject.Parent.Head
	else
		oldPart = cam.CameraSubject
	end
	if newSubject:IsA("Humanoid") then
		newPart = newSubject.Parent.Head
	else
		newPart = newSubject
	end
	local rPos = cam.CFrame.Position - oldPart.Position
	local camFrame = cam.CFrame
	cam.CameraType = Enum.CameraType.Scriptable
	local moveCon
	local totalTime = 0
	moveCon = RS.RenderStepped:Connect(function(dt)
        local newFrame = camFrame-camFrame.Position+newPart.Position+rPos
		totalTime = math.clamp(totalTime+dt/timeToTween, 0, 1)
		cam.CFrame = camFrame:Lerp(newFrame, totalTime)
		if totalTime == 1 then
			moveCon:Disconnect()
			cam.CameraSubject = newSubject
			cam.CameraType = Enum.CameraType.Custom
			moveCon = nil
		end
	end)
	repeat task.wait() until not moveCon
end

tweenCam(workspace.B)

task.wait(1)

tweenCam(game.Players.LocalPlayer.Character.Humanoid)

2 Likes

TYSM!! I figured it out now : )

Use parts instead of Instance.new(“Camera”), Instance.new(“Camera”) is only good for ViewPortFrames…

  • The camera is getting nil, after being cloned to workspace for some reason for the client.