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.

local Player = game.Players.LocalPlayer
local Camera = game.Workspace.CurrentCamera
local CameraObject = game.Workspace.CameraObject
local TweenService = game:GetService("TweenService")

Player.Character:Destroy()
wait(5)
Player.Character.Humanoid.Health = 0


repeat wait()
    Camera.CameraType = Enum.CameraType.Scriptable
until Camera.CameraType == Enum.CameraType.Scriptable


Camera.CFrame = CameraObject.CFrame

wait(10)
CameraObject.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.

CameraObject.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

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

Answer this question