Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why wont this work even with a for loop?

Asked by
Codebot 85
8 years ago

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
0
Please describe the intended behavior of the script so that we can better help you. Programmix 285 — 8y
0
You are checking for inequality of 2 X values of Position, which could be off by a really tiny amount. Try changing '~=' to '<' LetThereBeCode 360 — 8y

Answer this question