How would I keep the camera facing the player during a tween?

I’m moving the camera’s CFrame to a part’s CFrame, but I want it to still look at the player.

I’ve tried rotating the part and things like that, but none of them have worked.

Here’s a video of what I want it to look like: (i just want the first 2 parts, where the camera tweens away, and then back to the character)

and here’s what i have:

Here’s my script:

local camera = game.Workspace.CurrentCamera
local event = game.ReplicatedStorage.CameraMover
local TweenService = game:GetService("TweenService")
local player = game.Players.LocalPlayer

event.OnClientEvent:Connect(function(part)

	camera.CameraType = Enum.CameraType.Scriptable
	local tweeninfo = TweenInfo.new(3, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
	
	camera.CameraSubject = player.Character.Head
	TweenService:Create(camera, tweeninfo, {CFrame = CFrame.new(part.Position)}):Play()

	wait(3.3)

	TweenService:Create(camera, tweeninfo, {CFrame = CFrame.new(player.Character.Head.Position)}):Play()

	wait(3.3)

	camera.CameraSubject = player.Character.Humanoid
	camera.CameraType = Enum.CameraType.Custom

end)
3 Likes

tweening takes the target CFrame as it is so it wont be updated everytime to look at the player. u can make it look at the player by utilizing CFrame.LookAt function inside an renderstepped event

1 Like

I don’t know how I would put a render stepped event in here as I haven’t used them before. do you have any idea how I could put one in?

2 Likes

u can do it this way

local camera = game.Workspace.CurrentCamera
local event = game.ReplicatedStorage.CameraMover
local TweenService = game:GetService("TweenService")
local player = game.Players.LocalPlayer
local completed = false

event.OnClientEvent:Connect(function(part)

	camera.CameraType = Enum.CameraType.Scriptable
	local tweeninfo = TweenInfo.new(3, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
	
	camera.CameraSubject = player.Character.Head
	TweenService:Create(camera, tweeninfo, {CFrame = CFrame.new(part.Position)}):Play()

	wait(3.3)

	TweenService:Create(camera, tweeninfo, {CFrame = CFrame.new(player.Character.Head.Position)}):Play()

	wait(3.3)

	camera.CameraSubject = player.Character.Humanoid
	camera.CameraType = Enum.CameraType.Custom
        completed = true
        task.wait(1)
        completed = false
end)

local conn 
conn = game:GetService("RunService").RenderStepped:Connect(function()
	camera.CFrame = CFrame.new(camera.CFrame.Position, player.Character.Head.Position)
	if completed then conn:Disconnect() end
end)
1 Like

This doesn’t work.

It’s just constantly moving the camera, even when I haven’t used the spell.

1 Like

mb, please put it inside OnClientEvent

1 Like

It didn’t work at first, then when it reached the part, it worked, then stopped and when it got back to my head it killed me.

can anyone help? i’ve been trying different things and I still haven’t found one that works.

local camera = game.Workspace.CurrentCamera
local event = game.ReplicatedStorage.CameraMover
local TweenService = game:GetService("TweenService")
local player = game.Players.LocalPlayer

event.OnClientEvent:Connect(function(part)

	camera.CameraType = Enum.CameraType.Scriptable
	local tweeninfo = TweenInfo.new(3, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
	
	camera.CameraSubject = player.Character.Head
	TweenService:Create(camera, tweeninfo, {CFrame = CFrame.new(part.Position, player.Character.Head.Position)}):Play()

	task.wait(3.3)

	TweenService:Create(camera, tweeninfo, {CFrame = CFrame.new(player.Character.Head.Position, player.Character.Head.Position)}):Play()

	task.wait(3.3)

	camera.CameraSubject = player.Character.Humanoid
	camera.CameraType = Enum.CameraType.Custom
end)
2 Likes

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