How to I make a players camera follow a tween'd part. For example, this camera part on top of this car

trying to move the player’s camera to the position of the gray block for a cutscene, but not sure how to

In a LocalScript:

repeat wait() until game.Players.LocalPlayer.Character

local p = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
local part = nil -- the part you want to act as the camera

camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = part.CFrame + part.CFrame.LookVector

To revert back to looking at the human:

camera.CameraType = Enum.CameraType.Custom
camera.CameraSubject = p.Character.Humanoid
2 Likes

Thank you, do I put this anywhere specific?

In a LocalScript, so probably in whatever script you are doing your cutscene in.

Isn’t changing the pos of the cam, not sure why, no errors either.

Roblox core scripts might be overriding it so I’ll make it wait until those are loaded

But here’s the script in case I’ve done something wrong

repeat wait() until game.Players.LocalPlayer.Character

local p = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
local part = workspace.Car.CutSceneCar.Camera -- the part you want to act as the camera

repeat wait() until camera.CameraSubject ~= nil -- wait for roblox core scripts

camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = part.CFrame + part.CFrame.LookVector

Try this:

-- LocalScript

local RunService = game:GetService("RunService")
local Camera = workspace.CurrentCamera
local Part = workspace.Part -- Change this variable to your tweened part.

Camera.CameraType = Enum.CameraType.Scriptable

RunService.RenderStepped:Connect(function()
Camera.CFrame = Part.CFrame
end)
2 Likes

There’s two things you need to do, make the current camera able to be moved to specific locations, and repeatedly set it’s location to the target part’s location.

This will give us the ability to set the camera’s location manually

-- In a LocalScript
local Camera = workspace.CurrentCamera

Camera:GetPropertyChangedSignal("CameraType"):Connect(function()
    if Camera.CameraType == Enum.CameraType.Scriptable then return end

    Camera.CameraType = Enum.CameraType.Scriptable
end)

Camera.CameraType = Enum.CameraType.Scriptable

Continuing,

local RunService = game:GetService("RunService")

RunService.RenderStepped:Connect(function()
    Camera.CFrame = workspace.TargetPart.CFrame
end)
1 Like

Perfect, got it working, but is there any way I can activate it using a GUI image button?

You could make this script inside button, then you could do this

local RunService = game:GetService("RunService")
local button = script.parent
local Camera = game.Workspace.CurrentCamera
local Part = game.Workspace.Part -- Change this variable to your tweened part.
local isOn = false

button.MouseButton1Click:Connect(function()
	if not isOn then
		Camera.CameraType = Enum.CameraType.Scriptable
		isOn = true
	else
		Camera.CameraType = Enum.CameraType.Custom
		isOn = false
	end
end)

RunService.RenderStepped:Connect(function()
	if isOn then
		Camera.CFrame = Part.CFrame
	end
end)

1 Like
local RunService = game:GetService("RunService")
local currentcam = workspace.CurrentCamera
local c_c
local function ViewPart(Part)
currentcamera.CameraType = Enum.CameraType.Scriptable
c_c = RunService.RenderStepped:Connect(function()
currentcam.CFrame = Part.CFrame
end)
end
local function RemoveLookingPart()
c_c:Disconnect()
currentcamera.CameraType = Enum.CameraType.Custom
end

This is the best way to do it

1 Like

Worked perfectly, was even able to edit it for another purpose as well. Thank you

1 Like

Slightly Edited for an ImageButton

-- LocalScript

local RunService = game:GetService("RunService")
local Camera = workspace.CurrentCamera
local Part = workspace.Part -- Change this variable to your tweened part.
local Button = ScreenGui:FindFirstChild("ImageButton") -- Change this to your button

Button.MouseButton1Down:Connect(function()

repeat
Camera.CameraType = Enum.CameraType.Scriptable
wait()
until Camera.CameraType == Enum.CameraType.Scriptable

RunService.RenderStepped:Connect(function()
Camera.CFrame = Part.CFrame
end)
end)

One more thing, how do I return the cam?