Reversing for a,b loop

hello!
i made this code:

		for i = 1, #script.CHECKPOINT_Folder:GetChildren() do
				local anglePart = script.CHECKPOINT_Folder.Value[i]
				if anglePart then
					local Tween = game.TweenService:Create(script.Parent,TweenInfo.new(1,Enum.EasingStyle.Linear),{CFrame = anglePart.CFrame * CFrame.new(0,0,0)})
					Tween:Play()
					Tween.Completed:Wait()
					-- set camera to this anglePart's CFrame or something
				else
				end

		end

now its sends the part along the checkpoints, starting at the checkpoint called “1”
and ends at the last one. how would i makke it so it does this starting from the last one and stopping at the first one the most simple way?

for i = #script.CHECKPOINT_Folder:GetChildren(), 1, -1 do
    local anglePart = script.CHECKPOINT_Folder.Value[i]

is this what you mean?

if it will do what i saked for?
will it?

Try This:

for i = #script.CHECKPOINT_Folder:GetChildren(), 1, -1 do
	local anglePart = script.CHECKPOINT_Folder.Value[i]
	if anglePart then
		local Tween = game.TweenService:Create(script.Parent,TweenInfo.new(1,Enum.EasingStyle.Linear),{CFrame = anglePart.CFrame * CFrame.new(0,0,0)})
		Tween:Play()
		Tween.Completed:Wait()
		-- set camera to this anglePart's CFrame or something
	end
end

Good luck hope it works!

yes i willl try
thanks a lot for this (:

1 Like

that’s the same thing i said mate

1 Like

uhm actually its not. she sent the finished code like i needed and you sent a … not working code…

Please, mark the solution that works.

Both are right, first one just shown you the main aspect where second rewrote your code.

uhm actually i literally gave you the starting point. like a normal human being that anyone would’ve done, you shouldve matched the line of code i edited and replaced it, 9/10 times anyone would do that, i was simply asking a question if you meant that or not, and also the point of a post is to ask for help not full scripts, besides you didnt even ask for a full script, “how would i makke it so it does this starting from the last one and stopping at the first one the most simple way?”

none of them works in my case.

well should have led with that, now we can actually help.

are there any errors in the console or is it working differently to the way you want it to

Could you print the part and see whether the problem is because of something else.

the console looks empty on errors:


code:

EDIT: it seems like cutting off after finishing the first loop

The reason its not working is because you created the second loop wrong

where is my mistake? i cant seem to fiind it /:

replace for i = 1 where the second loop starts and replace it with this:
for i = #script.CHECKPOINT_Folder:GetChildren(), 1, -1 do

image

i did and it was red like this
image

Remove the 1, at the beginning completely
Just send the full code ill edit it