I am trying to make a cutscene with lots of tweens and that picks a random part to tween to.
But, around half of the time I play, it will just instantly jump to the next tween without any delay. It’s kind of hard to describe in words, so I’ll include a screen recording.
What it looks like when it doesn't work
Just don’t ask why I’m making a shreksophone game even after that meme is long gone, ok? It’s just for fun
What it's supposed to look like
There’s not anything I would know to try. Maybe it’s a TweenService glitch? Not sure what to do.
Also please don’t ask why I decided to make a shreksophone game It was just for fun, ok?
game.StarterGui:SetCoreGuiEnabled("All", false)
-- Wait for stuff to load
if not game:IsLoaded() then
game.Loaded:Wait()
end
-- Variables
game:WaitForChild("Workspace")
local ts = game:GetService("TweenService")
local uis = game:GetService("UserInputService")
local camera = game.Workspace.CurrentCamera
local player = game.Players.LocalPlayer
local tweenLength = math.random(0.3, 1.5)
local tweenInfo = TweenInfo.new(
tweenLength,
Enum.EasingStyle.Sine,
Enum.EasingDirection.Out,
0,
false,
0
)
uis.MouseIconEnabled = false
-- Functions
function tweenCamera(position1, position2, duration)
if duration == nil then
duration = tweenLength
end
camera.CameraType = Enum.CameraType.Scriptable
local tweenAnimation = ts:Create(camera, tweenInfo, {CFrame = position2})
tweenAnimation:Play()
wait(duration)
end
function tweenFov(fov1, fov2, duration)
if duration == nil then
duration = tweenLength
end
camera.CameraType = Enum.CameraType.Scriptable
local tweenAnimation = ts:Create(camera, tweenInfo, {FieldOfView = fov2})
tweenAnimation:Play()
wait(duration)
end
-- Cutscene
game.Workspace.Shreksophone:Play()
tweenCamera(game.Workspace.PianoCam.PianoCam1.CFrame, game.Workspace.PianoCam.PianoCam2.CFrame, 4)
tweenCamera(game.Workspace.PianoCam.PianoCam3.CFrame, game.Workspace.PianoCam.PianoCam4.CFrame, 5)
tweenCamera(game.Workspace.PianoCam.PianoCam1.CFrame, game.Workspace.PianoCam.PianoCam2.CFrame, 4)
while true do
local items = game.Workspace.ShrekCam:GetChildren()
local randomItem = items[math.random(1, #items)]
local randomItem2 = items[math.random(1, #items)]
spawn(function()
tweenCamera(randomItem.CFrame, randomItem2.CFrame, tweenLength)
end)
tweenFov(camera.FieldOfView, math.random(20, 120), 0.3)
wait(tweenLength)
end
The issue is that you’re making the Tween be too fast. Since, tweenlenght is choosing a random number between 0.3 and 1.5, it can either be ‘2 quick’, or ‘not 2 quick’. Then later, you made duration be tweenlenght. TweenLenght has not been looped, meaning it would always remain as one single number, meaning the time between every tween is gonna either be super fast, or fast.