Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Why doesn´t the camera rotate?

Asked by 5 years ago

I have recently made a camerapart, and attached the currentcamera to that part. Which works fine however, I also want to be able to rotate the camera, but the script doesn´t work.

01local Player = game.Players.LocalPlayer
02local Camera = game.Workspace.CurrentCamera
03local CameraObject = game.Workspace.CameraObject
04local TweenService = game:GetService("TweenService")
05 
06Player.Character:Destroy()
07wait(5)
08Player.Character.Humanoid.Health = 0
09 
10 
11repeat wait()
12    Camera.CameraType = Enum.CameraType.Scriptable
13until Camera.CameraType == Enum.CameraType.Scriptable
14 
15 
16Camera.CFrame = CameraObject.CFrame
17 
18wait(10)
19CameraObject.CFrame = CFrame.Angles(30,30,30)

1 answer

Log in to vote
2
Answered by
Elixcore 1337 Moderation Voter
5 years ago
Edited 5 years ago

Hey Andrius, in order to change a camera's CFrame you need to multiply the camera's current CFrame with the Angles you desire.

1CameraObject.CFrame = CameraObject.CFrame * CFrame.Angles(30,30,30)

Keep in mind CFrame.Angles takes radians so if you want to change the Angles by 30 degrees you will need to use math.rad

1CFrame.Angles(math.rad(30),math.rad(30),math.rad(30))
0
Oh, thanks :). AndriusTheGreat 140 — 5y
Ad

Answer this question