I want to shorten this code, but the problem is that it requires to go through different parts at a time. I looked at for loops, but they don’t seem to solve the problem.
Here is the code:
Code
local TweenService = game:GetService("TweenService")
--- Parts
local Model = workspace.Game.Islands.Spawn.Objects.Boat
local PartRoot = Model.Root
local Path = workspace.Game.BoatPath
--- Configurations
local TurnInfo = TweenInfo.new(
5,
Enum.EasingStyle.Quint,
Enum.EasingDirection.InOut,
0,
false,
0
)
local CheckpointInfo = TweenInfo.new(
20,
Enum.EasingStyle.Quint,
Enum.EasingDirection.InOut,
0,
false,
0
)
--- Wait Times
local Turn = 5
local Move = 20
local Dock = 5
--- Tweens
local C1 = TweenService:Create(PartRoot, CheckpointInfo, {CFrame = Path.Checkpoint1.CFrame}) --- Dock at Spawn
local C2 = TweenService:Create(PartRoot, CheckpointInfo, {CFrame = Path.Checkpoint2.CFrame})
local C3 = TweenService:Create(PartRoot, TurnInfo, {CFrame = Path.Checkpoint3.CFrame})
local C4 = TweenService:Create(PartRoot, CheckpointInfo, {CFrame = Path.Checkpoint4.CFrame})
local C5 = TweenService:Create(PartRoot, TurnInfo, {CFrame = Path.Checkpoint5.CFrame})
local C6 = TweenService:Create(PartRoot, CheckpointInfo, {CFrame = Path.Checkpoint6.CFrame})
local C7 = TweenService:Create(PartRoot, TurnInfo, {CFrame = Path.Checkpoint7.CFrame})
local C8 = TweenService:Create(PartRoot, CheckpointInfo, {CFrame = Path.Checkpoint8.CFrame}) --- Dock at Showcase Island
local C9 = TweenService:Create(PartRoot, CheckpointInfo, {CFrame = Path.Checkpoint9.CFrame})
local C10 = TweenService:Create(PartRoot, TurnInfo, {CFrame = Path.Checkpoint10.CFrame})
local C11 = TweenService:Create(PartRoot, CheckpointInfo, {CFrame = Path.Checkpoint11.CFrame})
local C12 = TweenService:Create(PartRoot, TurnInfo, {CFrame = Path.Checkpoint12.CFrame})
local C13 = TweenService:Create(PartRoot, CheckpointInfo, {CFrame = Path.Checkpoint13.CFrame})
local C14 = TweenService:Create(PartRoot, TurnInfo, {CFrame = Path.Checkpoint14.CFrame})
local C15 = TweenService:Create(PartRoot, CheckpointInfo, {CFrame = Path.Checkpoint15.CFrame}) --- Dock at Lighthouse Island
local C16 = TweenService:Create(PartRoot, CheckpointInfo, {CFrame = Path.Checkpoint16.CFrame})
local C17 = TweenService:Create(PartRoot, TurnInfo, {CFrame = Path.Checkpoint17.CFrame})
local C18 = TweenService:Create(PartRoot, CheckpointInfo, {CFrame = Path.Checkpoint18.CFrame})
local C19 = TweenService:Create(PartRoot, TurnInfo, {CFrame = Path.Checkpoint19.CFrame})
local C20 = TweenService:Create(PartRoot, CheckpointInfo, {CFrame = Path.Checkpoint20.CFrame})
local C21 = TweenService:Create(PartRoot, TurnInfo, {CFrame = Path.Checkpoint21.CFrame})
local C22 = TweenService:Create(PartRoot, CheckpointInfo, {CFrame = Path.Checkpoint22.CFrame})
local C23 = TweenService:Create(PartRoot, TurnInfo, {CFrame = Path.Checkpoint23.CFrame})
--- Process
wait(5)
while true do
C2:Play()
wait(Move)
C2:Cancel()
C3:Play()
wait(Turn)
C3:Cancel()
C4:Play()
wait(Move)
C4:Cancel()
C5:Play()
wait(Turn)
C5:Cancel()
C6:Play()
wait(Move)
C6:Cancel()
C7:Play()
wait(Turn)
C7:Cancel()
C8:Play()
wait(Move + Dock)
C8:Cancel()
C9:Play()
wait(Move)
C9:Cancel()
C10:Play()
wait(Turn)
C10:Cancel()
C11:Play()
wait(Move)
C12:Play()
wait(Turn)
C12:Cancel()
C13:Play()
wait(Move)
C13:Cancel()
C14:Play()
wait(Turn)
C14:Cancel()
C15:Play()
wait(Move + Dock)
C15:Cancel()
C16:Play()
wait(Move)
C16:Cancel()
C17:Play()
wait(Turn)
C17:Cancel()
C18:Play()
wait(Move)
C18:Cancel()
C19:Play()
wait(Turn)
C19:Cancel()
C20:Play()
wait(Move)
C20:Cancel()
C21:Play()
wait(Turn)
C21:Cancel()
C22:Play()
wait(Move)
C22:Cancel()
C23:Play()
wait(Turn)
C23:Cancel()
C1:Play()
wait(Move + Dock)
C1:Cancel()
end
I would appreciate any help. Thanks in advance!
Made the code above more compact without any unnecessary lines.