So I have a script here that basically animates a part which is connected to the players camera when they join, here is the script
local ts = game:GetService("TweenService")
local camera = workspace.CurrentCamera
local Points = game.Workspace.Cutscenes.Intro.Points
local Cam1 = game.Workspace.Cutscenes.Intro.Points:FindFirstChild("1")
local TweenTime = 3
local TweenInformation = TweenInfo.new(
TweenTime,
Enum.EasingStyle.Linear,
Enum.EasingDirection.In,
0,
false,
0
)
task.wait(2)
local Animating = true
local CurrentCamera = Instance.new("IntValue")
CurrentCamera.Value = 1
while Animating do
CurrentCamera.Value = CurrentCamera.Value + 1
print(CurrentCamera.Value)
local tween = ts:Create(camera, TweenInformation, {CFrame = Points:FindFirstChild(CurrentCamera.Value).CFrame})
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = Cam1.CFrame
tween:Play()
tween.Completed:Wait(1)
if CurrentCamera.Value == 9 then
Animating = false
end
end
I have a folder in workspace that has the 9 points that i want the players camera to move along with. What ends up happening is the camera starts at 1, then goes to 2, the restarts to 1, passes through 2 and goes to 3, then restarts at 1 again, passes through 2 and 3 and ends at 4, it does this all the way until number nine.
I’m wondering what I am doing wrong, and what changes I need to make to this script so that it doesn’t have to loop through everything 8 times before finally getting it right.