Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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 =)

2 comments

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.

0

Tween the camera to the player's HumanoidRootPart or Head or something and add a small vector3 away from the part.

1 answer

✓ Accepted answer

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

1 comment

0

AspectW ok! I will check it out. I will accept this answer. Thanks =)

This discussion is preserved as it was. New answers, comments, and votes are closed.