Having trouble move camera straight up

i have this code

local TweenService = game:GetService("TweenService")
local Camera = workspace.CurrentCamera

local TweenCameraFlyUpInfo = TweenInfo.new(4, Enum.EasingStyle.Quart, Enum.EasingDirection.Out)
local TweenCameraFlyUpTable = {CFrame = Camera.CFrame*CFrame.new(0,30,0)}
local CamFlyTween = TweenService:Create(Camera, TweenCameraFlyUpInfo, TweenCameraFlyUpTable)
CamFlyTween:Play()

but im tryna have it just fly straight up, but when it runs it kinda spirals out of control a lil
ive tried it with adding a vector instead of multiplying a cframe but i still get the same issue,
unsure whats going on or how to fix it

1 Like

could still use help on this, idk what to change to make this work

1 Like

Yeah, it’s probably something to do with the math. I’m not very good at it so I’ll leave this to others.

1 Like

Try setting the CameraType to Scriptable for the CurrentCamera

Camera.CameraType = Enum.CameraType.Scriptable

Good Day!
I’ve always had issues with tweening cameras directly, but what I do is create a part, and tween the part.

To attach the camera to the part, use RunService to attach the CFrame of the camera to the CFrame of the part.

Your script should look a little something like this

local TweenService = game:GetService("TweenService")
local Camera = workspace.CurrentCamera
local camPart = workspace.--campart name

local TweenCameraFlyUpInfo = TweenInfo.new(4, Enum.EasingStyle.Quart, Enum.EasingDirection.Out)
local TweenCameraFlyUpTable = {CFrame = Camera.CFrame*CFrame.new(0,30,0)}
local CamFlyTween = TweenService:Create(Camera, TweenCameraFlyUpInfo, TweenCameraFlyUpTable)
Camera.CameraType = Enum.CameraType.Scriptable

game:GetService("RunService").RenderStepped:Connect(function() -- Use RunService.Heartbeat if server script
	Camera.CFrame = camPart.CFrame
end)

I hope this helps, and if you have an issue I’d be happy to help!

2 Likes

I think it’s because you are multiplying the CFrame instead of adding a Vector3.
Here’s some documentation about CFraming, have a look at the Offsetting a CFrame section.

yeah, same here

well i dont think it would even work if it wasnt set to scriptable

ive tried doing something like

Camera.CFrame + Vector3.new(0,30,0)

and it had basically the same results as the cframe

ah, i see now
wonder why it doesnt work with using the camera.

ive even tried doing it in the command bar with just adding it straight up, no tweening and it would always mess with the orientation for some reason

1 Like

I think that it doesn’t work on camera bc a roblox script instantly overrides it, which shouldn’t really happen with roblox but, its roblox so what do you expect lol.

I figured out the cause of this problem, turns out

{CFrame = Camera.CFrame*CFrame.new(0,30,0)}

this code right here
broke it because every time it would move the camera, the tween would grab the cameras position at the new movement spot, which just kinda spiraled it out of control

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.