I have modified this script with help of the roblox wiki so that it executes with all the children of the desired model but because I'm using iterators it happens one part at a time, I'd like to know what should I use that that all the parts of the model move at the same time:
local buttonPressed = false
local wall = script.Parent.Parent.wall:GetChildren()
local dis =150
script.Parent.Touched:connect(function(part)
if not buttonPressed and part.Parent:findFirstChild("Humanoid", true) then
buttonPressed = true
script.Parent.BrickColor = BrickColor.new(21)
for i, v in pairs(wall) do
if v:IsA("Part")then
for i=0, dis do
v.CFrame = v.CFrame + Vector3.new(0,0,0.2)
wait()
end
wait(5)
for i=0, dis do
v.CFrame = v.CFrame + Vector3.new(0,0,-0.2)
wait()
end
end
end
wait(5)
script.Parent.BrickColor = BrickColor.new(309)
buttonPressed = false
end
end)

4 comments
I switched the loops but the parts still move one at a time, would you mind explaining it again? I'm pretty new so I get confused easily
I managed to make it work, thanks for your help. Now the model when it moves it looks like it vibrates any idea why this happens?
Are the parts that you're moving Anchored? If not they'll be falling in between moving them.
yes they are