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

How do I tween camera from Part to Original Camera Position?

Asked by
AbeTGT 4
4 years ago

Hey there! I'm just wondering, how do I tween camera from a Part or object to the original camera position that the player has.

So (I know that this probably doesn't work) but here's the basic Part to Part Tween:

local camera = workspace.CurrentCamera
local mainMenuMap = workspace:WaitForChild("MainMenuMap")

repeat wait()
    camera.CameraType = Enum.CameraType.Scriptable
until camera.CameraType == Enum.CameraType.Scriptable
camera.CFrame = mainMenuMap.CameraPart.CFrame

and for the Play Button (when press button on GUI) here's the localscript (still might not work for you but ok):

local camera = workspace.CurrentCamera
local mainMenuMap = workspace:WaitForChild("MainMenuMap")
local tweenService = game:GetService("TweenService")
local btn = script.Parent

function tweenCamera(pos,tweenTime)

tweenService:Create(camera,TweenInfo.new(tweentime,Enum.EasingStyle.Linear),{CFrame = pos.CFrame}):Play()
end

btn.MouseButton1Click:Connect(function()
    btn.Visible = false
    btn.Parent.Title.Visible = false -- Basically you would insert the code when the button is pressed

    tweenCamera(mainMenuMap,CameraPart2,1) -- The "1" is time of seconds to move the camera
    wait(1) -- We wait 1 second then...
    print("Reached Destination") -- Code here after camera has moved

So if you guys can help, please make an answer! Thanks =)

0
I am not 100% sure myself because I am fairly new to scripting but I think Tween uses position on the (for an object in game because you're making a camera move) x,y,z axises and also rotating axises, there doesn't seem to be any position or rotation values in your script, try making a tween function that moves the part from one designated position to another. Osamiku 12 — 4y
0
Tween the camera to the player's HumanoidRootPart or Head or something and add a small vector3 away from the part. bostaffmanbulgaria1 89 — 4y

1 answer

Log in to vote
0
Answered by
AspectW 431 Moderation Voter
4 years ago

Store the "original" Camera CFrame before you change it, and then simply tween the CFrame back to the variable.

0
AspectW ok! I will check it out. I will accept this answer. Thanks =) AbeTGT 4 — 4y
Ad

Answer this question