Orientation not working to change (Moving CurrentCamera)

I want it to face the portal and I cant get it.

This is my current code which barely works.

local Camera = game.Workspace.CurrentCamera
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local CameraPieceFinal = game.Workspace.CameraPieceFinal

--// joining

repeat wait() until Player.Character
print("yass repeating")

Camera.CameraType = "Scriptable"
Camera.CFrame = game.Workspace.CameraPiece.CFrame
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Health, false)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)

--Camera.CameraType = "Custom" incase you want back to regular camera


ChapterOneButton.MouseButton1Click:Connect(function()
	local time = 1
	local tweenInfo = TweenInfo.new(time, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)
	TweenService:Create(workspace.CurrentCamera, tweenInfo, {CFrame = CFrame.new(-515.835, 21.09, 127.772)}):Play()
	wait(1)
	CameraPieceFinal.CFrame = game.Workspace.CurrentCamera.CFrame:Lerp(CameraPieceFinal.CFrame, 0.5)
	
	game.Workspace.CurrentCamera.CFrame = CFrame.new(-515.835, 21.09, 127.772)
-- this line above is attempted to make it so it stays there (not working)
end)

Here is what I had to try and change the orientation but it isnt working.

local Camera = game.Workspace.CurrentCamera
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local CameraPieceFinal = game.Workspace.CameraPieceFinal

--// joining

repeat wait() until Player.Character
print("yass repeating")

Camera.CameraType = "Scriptable"
Camera.CFrame = game.Workspace.CameraPiece.CFrame
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Health, false)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)

--Camera.CameraType = "Custom" incase you want back to regular camera


ChapterOneButton.MouseButton1Click:Connect(function()
	local time = 1
	local tweenInfo = TweenInfo.new(time, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)
	TweenService:Create(workspace.CurrentCamera, tweenInfo, {CFrame = CFrame.new(-515.835, 21.09, 127.772) * CFrame.Angles(math.rad(0 ,(90) ,0))}):Play()
	wait(1)
	CameraPieceFinal.CFrame = game.Workspace.CurrentCamera.CFrame:Lerp(CameraPieceFinal.CFrame, 0.5)
	
	game.Workspace.CurrentCamera.CFrame = CFrame.new(-515.835, 21.09, 127.772)
end)

Video of what happens (With the second script) below

Argument 3 missing or nil - Client - Main:47

Video of what happens (With the first script) below

no errors scriptwise, but not facing or staying in position

Hi,

You don’t need to lerp anything really with TweenService.

A CFrame can be constructed in many ways, one way is like this -

CFrame.new(Position, LookAt) -- this is two vector three values, LookAt is the position you want to look at.

So instead of constructing the CFrame how you are, use CFrame.new(Position, LookAt) in your tweens. :slight_smile:

Would the LookAt just be the orientation ?

The Vector3 position you want the camera to look at, not orientation

So my script when the player clicks the button would just be

game.workspace.CurrentCamera.CFrame = game.Workspace.CameraPiece.CFrame:Lerp(CameraPieceFinal.CFrame, 0.5)

edit 1

this doesnt make it do anything, i removed this from the script.

This is the script now V

ChapterOneButton.MouseButton1Click:Connect(function()
	local time = 1
	local tweenInfo = TweenInfo.new(time, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)
	TweenService:Create(workspace.CurrentCamera, tweenInfo, {CFrame = CFrame.new(-515.835, 21.09, 127.772)}):Play()
	wait(1)
	
	--game.workspace.CurrentCamera.CFrame = game.Workspace.CameraPiece.CFrame:Lerp(CameraPieceFinal.CFrame, 0.5)
end)

it makes the camera move like before with the orientation messed up and then it goes back to the original camera

When you script the tween,

you would do something like this

local TweenService = game:GetService("TweenService")
local Cam = workspace.CurrentCamera

local MoveCam = TweenService:Create(Cam, TweenInfo.new(1), {CFrame = CFrame.new(PositionPart.Position, LookAtPart.Position)})
MoveCam:Play()

1 Like

Tried to do this…

ChapterOneButton.MouseButton1Click:Connect(function()
	local time = 1
	local tweenInfo = TweenInfo.new(time, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)
	TweenService:Create(workspace.CurrentCamera, tweenInfo, {CFrame = CFrame.new(Camerapiece.Position, CameraPieceFinal.Position)}):Play()
	wait(1)
	
	--game.workspace.CurrentCamera.CFrame = game.Workspace.CameraPiece.CFrame:Lerp(CameraPieceFinal.CFrame, 0.5)
end)

Now when the player clicks the button it just stays in place.
No errors