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

How to move multiple parts at the same time?

Asked by
zValerian 108
5 years ago
Edited 5 years ago

I have a script that is supposed to move three parts down at the same time since they are all named, 'test'. However, it only moves one part down. If I change it to make the color to red, it happens to all of them, whenever I try to make it move slowly down, it only happens to one of them. This is my script:

    for _, child in pairs(game.Workspace.test:GetChildren()) do
        -- Filter out non-part objects, such as Shirt, Pants and Humanoid
        -- R15 use MeshPart and R6 use Part, so we use BasePart here to detect both:
        if child.Name == "test" then
            while true do
            child.Position=child.Position+Vector3.new(0,-0.1,0)

            wait(.1)
            end
        end
    end

Only one part moves: https://gyazo.com/ec4688569c7a2a8abc2e8353d7fb6319

But if I make it

child.BrickColor = BrickColor.new("Really red")

It works for all of them, please help!

0
It has to do with the loop. It keeps running the loop and doesn't move on to the next line of code until the loop ends. Try using break greatneil80 2647 — 5y

Answer this question