Hey everyone! So today I wanted to practice with making tweens with cameras, so I made a script and got it to go the parts CFrame with no animation, now I wanted to try making the camera rotate 360 degrees in a while loop, I tried it, and I got an error, it said “Unable to cast to Dictionary” I know what the error means but I don’t really know how to fix it. here is my script…
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera
local TweenService = game:GetService("TweenService")
repeat wait()
Camera.CameraType = Enum.CameraType.Scriptable
until Camera.CameraType == Enum.CameraType.Scriptable
Camera.CFrame = workspace.Camerapart.CFrame
local info = TweenInfo.new(10,Enum.EasingStyle.Sine,Enum.EasingDirection.Out)
local rotate = workspace.Camerapart.CFrame * CFrame.Angles(math.rad(0), math.rad(360), math.rad(0))
local tween = TweenService:Create(workspace.Camerapart,info,rotate)
while true do
tween:Play()
wait(0.2)
end
If anyone knows how to fix this, please let me know! Thanks! (P.S, I am still new to scripting)
It look thats due to your CFrame.Angles, getting proper rotation with CFrames is something that takes a bit of time, but this article should help you with that.
I’m not sure what effect you’re looking for and am not too good with camera rotations via CFrames myself so my input will be pretty minimal. With your error sorted though, all it should take is some tweaking to get it looking right.
I just looked up some stuff on the devfourm and made a working script, here is the working script if you guys want to know.
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera
local TweenService = game:GetService("TweenService")
repeat wait()
Camera.CameraType = Enum.CameraType.Scriptable
until Camera.CameraType == Enum.CameraType.Scriptable
Camera.CFrame = workspace.Camerapart.CFrame
local info = TweenInfo.new(20,Enum.EasingStyle.Sine,Enum.EasingDirection.Out)
local rotating = true
while rotating do
local cameraTween = TweenService:Create(Camera,info, {CFrame = Camera.CFrame * CFrame.fromEulerAnglesXYZ(0, 360, 0);})
cameraTween:Play()
wait(0.02)
end