Camera will find a CFrame where the player is visible.
i Want the camera to look at the player when dead but the player’s camera when alive is in first person, which is i alr succeded but the problem is sometimes its glitching out the wall and the player is not visible.
Honestly, i’ve tried that
Unfortunately it was giving random parts from my map that i built.
The code:
workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
local vector = (workspace.CurrentCamera.CFrame.Position - player.Character.PrimaryPart.Position)
local direction = vector.Unit * vector.Magnitude
workspace.CurrentCamera.CFrame = CFrame.lookAt(player.Character.PrimaryPart.Position + Vector3.new(3, 9 ,7), player.Character.PrimaryPart.Position)
local part = workspace:Raycast(workspace.CurrentCamera.CFrame.Position, direction)
if part then
print(part.Instance:GetFullName())
end
local cameraCFrame = currentCFrame.CFrame:PointToWorldSpace(Vector3.new(3, 9 ,7)) -- Vector3 is the offset not sure if this is the correct of set you want.
local cameraFocus = Character:GetPivot():PointToWorldSpace()
local part = workspace:Raycast(cameraFocus, cameraCFrame - cameraFocus)
if part then
...
end