Trying to change camera subject on equip

So I was trying to make a tool that makes the camera focus on a part on equip and when you unequip it, it focuses back on the player. But the problem is that the camera only rotates to the part’s orientation and I didn’t want the camera to rotate. I wanted the camera to focus on a part. So can y’all help me? Here is my script.

task.wait()

local tool = script.Parent
local cam = workspace.CurrentCamera
local part = workspace:WaitForChild("CamPart")

tool.Equipped:Connect(function()
	cam.CameraType = Enum.CameraType.Track
	cam.CFrame = CFrame.new(part.Position)
end)
--unequip was a test
tool.Unequipped:Connect(function()
	cam.CFrame = CFrame.new(part.Position)
end)
2 Likes

CameraSubject should probably be sufficient:

local Tool = script.Parent
local Camera = workspace.CurrentCamera
local Part = workspace:WaitForChild("CamPart")

Tool.Equipped:Connect(function()
	Camera.CameraType = Enum.CameraType.Track
	Camera.CameraSubject = Part
end)

Tool.Unequipped:Connect(function()
	Camera.CameraType = Enum.CameraType.Custom
	Camera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
end)
1 Like

It works perfectly! Thank you!

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