How Do I Return The Camera to The Player After the CFrame has been set to a part

I’ve tried

Camera.CameraSubject = game.Players.localPlayer.character.Humanoid
 		
 Camera.CameraType = Enum.CameraType.Custom

As well as some other method’s, nothing’s seems to have worked yet. Here’s my script.

local RunService = game:GetService("RunService")
local button = script.Parent.ImageButton
local Camera = game.Workspace.CurrentCamera
local Player = game:GetService("Players")
local Part = game.Workspace.Car.CutSceneCar.Camera
local isOn = false

button.MouseButton1Click:Connect(function()
	wait()
	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)

-- return cam to player

wait(15) -- change to 65 after testing
Camera.CameraType = Enum.CameraType.Custom

Camera.CameraSubject = Player.LocalPlayer.Character.Humanoid

Camera.CameraType = Enum.CameraMode.LockFirstPerson

I don’t see a RunService variable, Is this the full script?

local RunService = game:GetService("RunService")

Yeah it is the full script
(Char limit aaaaaa)

nvm, thought it was. gonna fix that

does this fix it

local RunService = game:GetService("RunService")
local Player = game:GetService("Players")

local button = script.Parent.ImageButton
local Camera = game.Workspace.CurrentCamera
local Part = game.Workspace.Car.CutSceneCar.Camera
local isOn = false

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

Part:GetPropertyChangedSignal("CFrame"):Connect(function()
	if isOn then
		Camera.CFrame = Part.CFrame
	end
end)

-- return cam to player

wait(15) -- change to 65 after testing
Camera.CameraType = Enum.CameraType.Custom
Camera.CameraSubject = Player.LocalPlayer.Character.Humanoid
1 Like

Figured out the problem was the loop changing the CFrame of the cam constantly, so all I had to do was make sure the loop stopped. Thanks for the help though!