Obby placer not working

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? I am trying to make a script place each obby stage in the right order

  2. What is the issue? It only moves Stage1 to the set position in the script, but not the other stages.
    image
    I am also launching this from the console


    Only prints “no” (from stage 1).

  3. What solutions have you tried so far? I was looking for other ways to do this, but I couldn’t understand some solutions.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

 for i,v in pairs(game.Workspace.Stages:GetChildren()) do
	if v.Name == ("Stage".. tostring(i)) then
		if i == 1 then
			v:MoveTo(Vector3.new(0, 15, 0))
			print('no')	return
		end
		local stage = v
		print(stage.Name)
		local oldstage = ("Stage" .. tostring(i - 1))
		stage:MoveTo(oldstage.Position + Vector3.new(0, 0, 43))
	end
end

All help is appreciated!!

1 Like

Does return stop the whole loop? I thought that’s was what break was for.

I edited the code, but still same output.

for i,v in pairs(game.Workspace.Stages:GetChildren()) do
	if v.Name == ("Stage".. tostring(i)) then
		if i == 1 then
			v:MoveTo(Vector3.new(0, 15, 0))
			print('no')	return
		else
		local stage = v
		print(stage.Name)
		local oldstage = ("Stage" .. tostring(i - 1))
		stage:MoveTo(oldstage.Position + Vector3.new(0, 0, 43))
		end
	end
end

I see your issue and have run into the same issue a thousand times before.

If were talking about the same thing this should be the solution:

for i,v in pairs(game.Workspace.Stages:GetChildren()) do
	if v.Name == ("Stage".. tostring(i)) then
			v:MoveTo(Vector3.new(0, (i-1)* 15, 0))
	end
end

What this will do is instead of checking if it is one to move it to the starting location, it will move it to i-1 which would put 1 at the start(0, 0, 0) and two at 1 * 15 and 3 at 2 * 15 and so on… Basically removing a step off of all of the positions.

1 Like

Don’t worry, It’s quite an annoying one!

I just changed the Y value to the X value and worked perfect!

1 Like