Script not working when changing number to somthing else

Hey! My code isn’t working when i changing the 10, but i need to change number to variable

task.spawn(function()
for j = MovingTo.Value, #Multiway['1']:GetChildren() do -- here problem, when i use anything else but not number it not running code
              print(j)
       end
end)

What do you mean by “10”?
Give an example of what you want to do.

task.spawn(function()
for j = MovingTo.Value, #Multiway['1']:GetChildren() do
              print(j)
       end
end)

if i change "#Multiway[‘1’]:GetChildren() " to 10 it will work, but with this it doesn’t working

I assume either :GetChildren() is 0 or :GetChildren() is smaller than the movetoValue

So can you print the movetoValue and the #multiway … for us please?

Try to print this:

print(#Multiway['1']:GetChildren())

tell me what you got in output,
It has to be a number!

OH YEA THATS IT, but how then i need to do points? Like i have points for moving character and i have another folder with another points

Like i have folder with parts named {1, 2, 3, 4, 5, 6…} and another folder with next points {7, 8, 9, 10, 11…}

Idk what you mean, what does that even print exactly?

print(#Multiway['1']:GetChildren())

6, in another folder I have 3 points that named {8, 9, 10}
image

how can it print 6?

in the “1” Folder, there are 4 Parts, so it has to print 4 instead of 6

in folder “points” it have 6 parts, in folder ‘1’ it have 4 parts

What is the MovingTo.Value? It must be smaller than 4. Can you print it for us?

for i = tonumber(MovingTo.Value), #Path.Points:GetChildren() do
				if Humanoid.Health > 0 then
					local Point = Path.Points:FindFirstChild(tostring(i))
					local Multiway = Path.Points:FindFirstChild('Multiway'):: Folder

					if Point then
						Humanoid:MoveTo(Point.Position)
						Humanoid.MoveToFinished:Wait()
						MovingTo.Value = i
					end

					if i == #Path.Points:GetChildren() then
						if Multiway then
							local children = Multiway['1']:GetChildren()
							local length = #children
							
							task.spawn(function()
								for j = MovingTo.Value, length do
									print(j)
								end
							end)
						else
							
							Humanoid:MoveTo(Path.Exit.Position)
							Humanoid.MoveToFinished:Wait()
							
							if Enemy.Name == 'Arrow' then
								Enemy:Destroy()
							else
								Enemy:Destroy()
							end
						end
					end
				end
			end

but

#Multiway['1']:GetChildren()

means, that it should print how manny elemts are in: Multiway[‘1’]
in Multiway[‘1’] there are 4 Elements,

so why it prints 6

in folder points it have 6 parts…

WHAT VALUE IS MOVINGTO
aksksknzns

it changing to value what model moving to

Bro, in Multiway['1] there are 4 Elements

I need the exact number please tell me
snzjzjsksks

i can’t say this to you, like i have folder “points” and moving model to every point on this folder