Setting the Player's Camera to a Part's Perspective

Setting the Player’s Camera to a Part’s Perspective

So I just want to make a simple cutscene and change the player’s view to a part’s view. The only problem is that the camera is facing in the wrong direction. Here is the module script:

local module = {}

local rig = game.Workspace:WaitForChild("Rig")
local rigPrim = rig:WaitForChild("HumanoidRootPart")
local mainFrame = rigPrim.CFrame
rig:Destroy()

module.FirstCam = function(plr: Player,camera,targetPart: Part) -- camera function
	local char = plr.Character or plr.CharacterAdded:Wait()
	local hrp = char:WaitForChild("HumanoidRootPart")
	local hum = char:WaitForChild("Humanoid")
	hum.WalkSpeed = 0
	hum.JumpPower = 0
	hrp.Anchored = true
	hrp.CFrame = mainFrame
	camera.CameraType = Enum.CameraType.Fixed
	camera.Focus = targetPart.CFrame -- sets the player's camera to that part
end
	
return module

It’s setting the position of the camera to the part’s position but not the rotation? It doesn’t matter if I change the camera part’s rotation, it just stays the same. All I’m trying to do is get the camera rotation facing in the front direction of the camera part.

1 Like

You are focusing on the targetPart, meaning the Camera will look at the targetPart. You need to set the Camera CFrame instead, So it will be placed where the targetPart is.

Try this:

camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = targetPart.CFrame

Thanks for that @MilkyFiend

Do you know why you have to change the CameraType tho?

1 Like

It is probably because each camera type serve different purposes. For example CameraType.Custom allows the player to freely move around the camera while locking on the the subject. It’s by default. On the other hand Scriptable allows devs to freely edit the camera to make their custom stuffs like cutscenes or a custom camera system.

I’d recommend you check the documentation if you wish to learn more about this matter : CameraType

1 Like

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