I have this script which tweens a camera over a wide area. It works for the most part. However, when certain tween positions were chosen, the camera didn’t move. The tween does play because tween.Completed:Wait() gets fired, but the camera doesn’t move.
local tweens = {
{workspace.A, workspace.C, workspace.BallSpawnPositions.KickOff},
{workspace.D, workspace.B, workspace.BallSpawnPositions.KickOff},
{workspace.CentreCamera, workspace.BlueCamera, workspace.BlueCamera}, <-- when this is chosen, the camera doesn't move.
{workspace.CentreCamera, workspace.GreenCamera, workspace.GreenCamera} <-- when this is chosen, the camera doesn't move.
}
local function TweenCamera(begin: boolean)
if currentTween then
currentTween:Cancel()
currentTween:Pause()
currentTween = nil
end
if not begin then
tweening = false
camera.CameraType = Enum.CameraType.Custom
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
camera.CameraSubject = humanoid
return
end
camera.CameraType = Enum.CameraType.Scriptable
camera.CameraSubject = nil
tweening = true
task.spawn(function()
while tweening do
local selectedtween = tweens[math.random(1, #tweens)]
local start = selectedtween[1]
local finish = selectedtween[2]
local lookat = selectedtween[3]
print(start, finish, lookat)
camera.CFrame = CFrame.new(start.Position, lookat.Position)
local goal = {}
goal.CFrame = CFrame.new(finish.Position, lookat.Position)
currentTween = tweenservice:Create(camera, TweenInfo.new(20, Enum.EasingStyle.Linear), goal)
if tweening then
currentTween:Play()
local start = tick()
tween.Completed:Wait()
Transition(transition)
end
end
end)
end
Things I’ve tested:
I’ve checked that the starting and finishing locations are different parts.
I’ve checked that the positions of the start and finish are different.
I’ve printed the Enum of the tween, and it tells me it is playing.
When the loop chooses the 1st and 2nd tween, the script functions as expected.