So at first I put a part named main and a part named wall in a model. My script worked perfectly! As soon as I added a second part under the name "wall", the script no longer works. The script was never modified. I even deleted the 2nd "wall" and then it worked :l

p = game.Workspace.Model.main
gamee = game.Workspace.Model:GetChildren() 
for i = 1,#gamee do
	if gamee[i].Name == "wall" then
		print("X:"..gamee[i].CFrame.X)
while (p.Position.X) ~= (gamee[i].Position.X -4) do
	wait(.1)
	p.Position = p.Position + Vector3.new(1,0,0)
end
end
end

2 comments

0

Please describe the intended behavior of the script so that we can better help you.

0

You are checking for inequality of 2 X values of Position, which could be off by a really tiny amount. Try changing '~=' to '<'