My CFrame camera angle is not working

Here is my camera script so could anyone possibly help me fix this camera issue here is my script.

game.Workspace.Camera.CameraType = Enum.CameraType.Scriptable

game.Workspace.Camera.CFrame = CFrame.new(game.Workspace.IntroTunnel.CameraOrigin.Position,game.Workspace.IntroTunnel.CameraFace.Position)

So I am not very good at scripting so is there a code I can copy or is there just a formate, thanks!

Hello your post has been withdrawn could you put it back up or recreate it please?

Your code did not work could you fix it please?

What is your goal? To determine when a player looks at an object?

No my goal is to determine to make a player look at an object

Wait correction to make a player look at an object.

If you want to change what the player see’s via their camera you could do:

local Player = game:GetService('Players').LocalPlayer
local PlayersCurrentCamera = workspace.CurrentCamera
local PartToMakeCharacterView = workspace.PartToMakeView

PlayersCurrentCamera.CFrame = PartToMakeCharacterView.CFrame

This should give you a basic understanding, if you want a player to be able to view a certain area, you can put a part in that area, angle it how you want, then change the current cams CFrame. If this is the solution be sure to mark it as the solution!

So should I have a camera origin and a camera face or just one?

With the code I gave you above, you don’t need to do put anything in but a part, and replace
local PartToMakeCharacterView = workspace.PartToMakeView, specifically workspace.PartToMakeView with where you stored & named the part you’re trying to make the character view. The script I posted above will simply get the Players Current Cam, and make the CFrame equal to that of the part. Be sure it’s a local script inside of StarterPlayerScripts!

Hey, I haven’t heard anything about CFrame.new() being deprecated. I just went to the wiki and it didn’t say that either.

Could you please provide a link that backs this claim? I would love to learn more if I could.

Thank you.

4 Likes

Ok so for the last line of code would this work? PlayersCurrentCamera.CFrame = workspace.CameraFace.CFrame

Yes it would! One thing I’d do to be safe is add a WaitForChild in-case the script runs before the game is loaded, you can do that by doing PlayersCurrentCamera.CFrame = workspace:WaitForChild("CameraFace").CFrame

:WaitForChild() will yield [stop] the script until CameraFace is found and loaded!

If this was the solution to your problem be sure to mark it as the solution! Glad to help!

CFrame.fromMatrix() is pretty complex for beginners and CFrame.new(pos, lookAt) works perfectly fine

1 Like

Here is my script its not working could you please help me fix it further?
local Player = game:GetService(‘Players’).LocalPlayer

local PlayersCurrentCamera = workspace.CameraFace

local PartToMakeCharacterView = workspace.CameraFace

PlayersCurrentCamera.CFrame = workspace:WaitForChild(“CameraFace”).CFrame

It’s not working because PlayersCurrentCamera is the players current camera, but you currently have it to what you’re trying to make the CFrame of the current camera go to. You need to change local PlayersCurrentCamera = workspace.CameraFace to local PlayersCurrentCamera = workspace.CurrentCamera. So in the end this should be your full script:

local PlayersCurrentCamera = workspace.CurrentCamera
local PartToMakeCharacterView = workspace.CameraFace
PlayersCurrentCamera.CameraType = Enum.CameraType.Scriptable --Makes it so you can change the CFrame of the camera 

PlayersCurrentCamera.CFrame = workspace:WaitForChild(“CameraFace”).CFrame --Changes the CFrame

This script is still not working and my script is a local script in starter player scripts and the name of it is camera and here is the code local PlayersCurrentCamera = workspace.CurrentCamera

local PartToMakeCharacterView = workspace.CameraFace

PlayersCurrentCamera.CameraType = Enum.CameraType.Scriptable --Makes it so you can change the CFrame of the camera

PlayersCurrentCamera.CFrame = workspace:WaitForChild(“CameraFace”).CFrame --Changes the CFrame

It didn’t work because for some reason your keyboard made the " weirdly formatted, in a way ROBLOX LUA does not accept. This should be your script

local Player = game:GetService(‘Players’).LocalPlayer

local PlayersCurrentCamera = workspace.CurrentCamera

local PartToMakeCharacterView = workspace:FindFirstChild(“CameraFace”)

PlayersCurrentCamera.CameraType = Enum.CameraType.Scriptable

PlayersCurrentCamera.CFrame = PartToMakeCharacterView.CFrame --Changes the CFrame

Put the local script into StarterCharacterScripts, not StarterPlayerScripts, my apologies.

1 Like