Wall movement issue(Fixed)

I’m working on making moving walls in 1 script, but 2 of the walls aren’t working. I’m using an if statement for all of the walls. I’ve tried to use elseif statements as well and if statements with and and or, but it hasn’t worked.

for i,v in pairs(game.Workspace.MovingWalls:GetChildren()) do
	while true do
		wait(1)
		if v.Name == "MovingWall" then
			print("MovingWall IFed fine.")
			for i = 1,30 do
				v.CFrame = v.CFrame * CFrame.new(0.3,0,0)
				task.wait()
			end
			for i = 1,30 do
				v.CFrame = v.CFrame * CFrame.new(-0.3,0,0)
				task.wait()
			end
		end
		if v.Name == "MovingWall2" then
			print("MovingWall2 IFed fine.")
			for i = 1,30 do
				v.CFrame = v.CFrame * CFrame.new(-0.3,0,0)
				task.wait()
			end
			for i = 1,30 do
				v.CFrame = v.CFrame * CFrame.new(0.3,0,0)
				task.wait()
			end
		end
		if v.Name == "MovingWall3" then
			print("MovingWall3 IFed fine.")
			for i = 1,30 do
				v.CFrame = v.CFrame * CFrame.new(-0.3,0,0)
				task.wait()
			end
			for i = 1,30 do
				v.CFrame = v.CFrame * CFrame.new(0.3,0,0)
				task.wait()
			end
		end
	end
end

probably use tweenservice with no tween.complete but if you really need to use it then put it in a coroutine.wrap(function() since i think that the task.wait is affecting the others

1 Like