Wait yields the current thread until the given time has elapsed. I’d recommend using this, it may work better:
for i = 1, MaxVal do
Camera.CameraType = Enum.CameraType.Scriptable
local TweenHere = TweenService:Create(Camera, TweenInfo.new(CurrentTime, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0), {CFrame = TotalCamera{i + 1}.CFrame}):Play()
TweenHere.Completed:Connect(function()
print("Status: Tween Completed!")
end
end
Side note: It is recommended to post the actual code here, and not the image of it!
As @MeCrunchAstroX said, Tween:Play() doesn’t return the Tween. In other words, it’s not really ‘chainable’.
Besides that, I really recommend you create a wrapper library for tweening functions as it can make playing tweens & being able to get it from that really useful, especially for animated interfaces!
Here’s the one I use as an example:
local TweenService = game:GetService("TweenService")
local Tween = {}
function Tween:Create(Instance: Instance, tweenInfo, Properties): Tween
if typeof(tweenInfo) == "table" then
if tweenInfo[2] and typeof(tweenInfo[2]) == "string" then
tweenInfo[2] = Enum.EasingStyle[tweenInfo[2]]
end
if tweenInfo[3] and typeof(tweenInfo[3]) == "string" then
tweenInfo[3] = Enum.EasingDirection[tweenInfo[3]]
end
tweenInfo = TweenInfo.new(unpack(tweenInfo))
end
return TweenService:Create(Instance, tweenInfo, Properties)
end
function Tween:Play(Instance: Instance, tweenInfo, Properties): Tween
local NewTween = self:Create(Instance, tweenInfo, Properties)
NewTween:Play()
return NewTween
end
return Tween
Usage:
local Tween = require(path.to.Tween)
local NewTween = Tween:Play(Gui.Frame, {1, "Sine", "Out"}, {Transparency = 1}) -- Automatically runs Tween.Play and returns Tween
if NewTween.PlaybackState == Enum.PlaybackState.Playing then
NewTween.Completed:Wait()
end