PokeCedGo
(PokeCedGo)
August 29, 2022, 6:39pm
#1
I’m having trouble on how I would “reverse” the tween animation so its like moving to the part I want it to but backwards so it looks smoother instead of turning to the part.
https://gyazo.com/8affca130c47bcb6e3527fbe26314cc3
The Code
script.Parent.MouseButton1Click:Connect(function()
script.Parent.Parent.Visible = false
local UIS = game.Players.LocalPlayer.PlayerGui
script.Parent["MMZ - Menu Selected"]:Play()
local tweens = game:GetService("TweenService")
local userInput = game:GetService("UserInputService")
local camera = workspace.CurrentCamera
local oldCamera = camera.CFrame
oldCamera = camera.CFrame
camera.CameraType = Enum.CameraType.Scriptable
local part = workspace.GameCameras.introcam
local unit = (camera.CFrame.Position - part.Position).Unit
local distance = (camera.CFrame.Position - part.Position).Magnitude
local tween = tweens:Create(camera, TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {CFrame = CFrame.lookAt(camera.CFrame.Position - unit * (distance * 0.8), part.Position)})
tween:Play()
task.wait(0.5)
script.Parent.ScrollingSound:Play()
tween.Completed:Wait()
--[ Make the UIs visible again]
UIS.MenuOverlays.Settings.Visible = true
UIS.IsAtStart.Value = true
end)
Katrist
(Katrist)
August 29, 2022, 6:57pm
#2
The tweens always take the shortest route, so you’re going to have to move the camera over closer to the part before tweening them.
If you are talking about something else please tell me.
PokeCedGo
(PokeCedGo)
August 29, 2022, 7:01pm
#3
I think you understand it, but to clarify, just think of a person walking backwards
Hey, the TweenInfo
object has the TweenInfo.Reverses
property which is the last, so if you want to reverse it you would need to set that to true! Check this out for more info TweenInfo
Katrist
(Katrist)
August 29, 2022, 7:04pm
#5
Oh okay, thanks for clarifying.
Try this:
script.Parent.MouseButton1Click:Connect(function()
script.Parent.Parent.Visible = false
local UIS = game.Players.LocalPlayer.PlayerGui
script.Parent["MMZ - Menu Selected"]:Play()
local tweens = game:GetService("TweenService")
local userInput = game:GetService("UserInputService")
local camera = workspace.CurrentCamera
local oldCamera = camera.CFrame
oldCamera = camera.CFrame
camera.CameraType = Enum.CameraType.Scriptable
local part = workspace.GameCameras.introcam
local unit = (camera.CFrame.Position - part.Position).Unit
local distance = (camera.CFrame.Position - part.Position).Magnitude
local tween = tweens:Create(camera, TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, true), {CFrame = CFrame.lookAt(camera.CFrame.Position - unit * (distance * 0.8), part.Position)})
tween:Play()
task.wait(0.5)
script.Parent.ScrollingSound:Play()
tween.Completed:Wait()
--[ Make the UIs visible again]
UIS.MenuOverlays.Settings.Visible = true
UIS.IsAtStart.Value = true
end)
PokeCedGo
(PokeCedGo)
August 29, 2022, 7:07pm
#6
I read the page, just confused when to set it to true in my code
Replace it with this
local tween = tweens:Create(camera, TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, true), {CFrame = CFrame.lookAt(camera.CFrame.Position - unit * (distance * 0.8), part.Position)})
PokeCedGo
(PokeCedGo)
August 29, 2022, 7:19pm
#8
I guess it works ty! I was hoping for it to not turn around then face back and more of a “tween backwards like its walking backwards” type but this is fine!
https://gyazo.com/1570cbf58b7bc1df4ae9a8abcaeeee6d
No worries, don’t forget to mark it as your solution
to the problem!