Now let’s make an array with all the CFrames (CFrames are positions with the orientation in radiants)
local CFrames = {...}
An example could be:
local CFrames = {
workspace:WaitForChild("Spot1").CFrame, -- dont forget the comma
workspace:WaitForChild("Spot2").CFrame
}
Then we will make an index value for the while loop, we wont use a for loop, because we cannot make that run for ever.
local i = 1
Then each time a tween is finished we will have to add a value to it
i += 1
Then if the index is bigger than the size of the array we will have to set it back to 1. We can use % with that.
local arraySize = #CFrames
i = (i-1)%arraySize + 1
Quick showcase of %
1%5 = 1
5%5 = 0
6%5 = 1
8%5 = 3
12%5 = 2
-- etc.
Now we first remove a value from the index because we still want it to be 4 and we dont want it to be 0. After we cant forget to add the value back.
Now if we combine this with i += 1 it would become
i = (i-1)%#CFrames+ 2
Now it would look something like this:
local CFrames = {...}
local i = 0
while true do
i = (i-1)%#CFrames+ 2
local nextCFrame = CFrames[i] -- CFrame you want it to set
local tween = TweenService:Create(balloon, tweenInfo, {
["CFrame"] = nextCFrame
})
tween:Play()
tween.Completed:Wait() -- wait for it to complete
end
local balloon = script.Parent
local TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(
15, -- Time
Enum.EasingStyle.Linear, -- Easinmg Style
Enum.EasingDirection.Out, -- Easing Direction
-1, -- Repeat Count
false, -- Reverse
0 -- Delay Time
)
local CFrames = -{game.Workspace.Waypoints["waypoint 1"],
game.Workspace.Waypoints["waypoint 2"],
game.Workspace.Waypoints["waypoint 3"],
game.Workspace.Waypoints["waypoint 4"]
}
local i = 0
while true do
i = (i-1)%#CFrames+ 2
local nextCFrame = CFrames[i] -- CFrame you want it to set
local tween = TweenService:Create(balloon, tweenInfo, {
["CFrame"] = nextCFrame
})
tween:Play()
tween.Completed:Wait() -- wait for it to complete
end
Move it off from any of the waypoints, it could be trying to move to waypoint 1, while it is already on it. Then it would take 15 seconds until it does start moving.
What I meant is, can you change the position of the balloon inside ROBLOX studio. Move it away from any Waypoints, put it on Waypoint 4 or change the time it takes to move from 15 to 1 while testing.