How can I rotate the camera when its attached to a Part in the workspace

My current code is

local cam = game.Workspace.CurrentCamera
local part = game.Workspace.SpawnCamera

cam.CameraType = 'Scriptable'
cam.CameraSubject = part
wait(0.5)
cam.CoordinateFrame = CFrame.new(part.Position) CFrame.Angles(180, 0, 0)

It is still constantly facing a 0 degree angle, how can I rotate it so that its facing a different angle? I want to change this because of the lighting. Thanks in advance!

3 Likes

Change this to:

   part.CFrame = part.CFrame * CFrame.fromEulerAnglesXYZ(0, 0, 0) -- change whatever here
2 Likes

Thanks you so much! I had been looking on the Wiki for so long and I couldn’t figure it out…

1 Like

If you need more information on Camera Manipulation, you can use the following link:

https://developer.roblox.com/articles/Camera-manipulation

1 Like

Make sure to mark the previous post as the solution then :smile:

1 Like

Well it seems jumped the gun… I had replaced the code and saw that the camera angle did indeed change, but when I edit the values, nothing changes… :frowning:

I edited the previous post, should work now.

Unfortunately, I’m still not having any luck…

Here’s the place file
Hyrule Cam Test.rbxl (674.8 KB)

The camera script is under StarterPlayerScripts and its named CameraScript

Spelling and capitalization are extremely important in coding. The “cam.Cframe” should be “cam.CFrame”. That should work.

local cam = game.Workspace.CurrentCamera
local part = game.Workspace.SpawnCamera


cam.CameraType = 'Scriptable'
cam.CameraSubject = part
wait(0.5)
part.CFrame = part.CFrame * CFrame.fromEulerAnglesXYZ(90, 90, 0) -- change whatever here

@JasonHemsworth is right, you had typed fromEulerAnglesXYZ as FromEulerAnglesXYZ.

I copied and pasted exactly what was put in your most recent reply and I’m still having no luck in seeing any changes

Could you explain in more detail on what you’re trying to achieve?

Yes,

I am trying to achieve a 2D Platformer view where the camera is Stationary for everyone one. (I’m just attempting to make a Super Smash Bros style game, as replicating it is really technical and advanced so I’m just learning right now…) Currently the camera is facing 180 degrees opposite on the X-Axis than where I would like it to be looking. If I need to clarify anything just let me know.

You want the camera to be like this?


Image from Google Images

Basically yes, right now I have it stationary viewing the map in its entirety because I couldn’t figure out how to get it to follow the player but have a boundary on the side. I already have it stationary, Its just facing the wrong way…

EDIT: https://gyazo.com/91183c160908c0589702e52d1b4baf0f

Try changing the angles by doing:

camera.CFrame = camera.CFrame * CFrame.fromEulerAnglesXYZ(0, 90, 0)

if that doesn’t fix the problem try

camera.CFrame = camera.CFrame * CFrame.fromEulerAnglesXYZ(0, 0, 90)

1 Like

I’m atleast able to see movements in the camera, I just cant figure out the correct values, but I’m reading the Wiki page on it @ https://developer.roblox.com/articles/Euler-Angles Thanks for your help!

No problem. Just reply if you need anything.

What you can do is move the camera part to the other side of the contraption, and then rotate that contraption so it faces the part. That will make the camera face that tower.

Yes I understand that, but I want to have the lighting stay the same for the scene, I would just have to flip the Time settings, but I believe learning this script will help me in the long run…