Well, I assume that you want parts to rotate randomly. Well, if you want to rotate them instantly, you can do :
child.Orientation = container[math.random(1, #container)]
So, you might be thinking what we just did. Well, let's first talk inside the brackers, i.e., math.random(1, #container), here, 1 is a number and #container is the maximum number, which is the total number of elements in your array. So, math.random is taking random between 1 and largest number (2 in your case). And now, we have a random number, we just apply that number to that table, so we get our value.
NOTE : Don't use this method, if you are finding a random element in a Dictionary. In your case, it's an array, so it will work.
Also, if you want to animate the parts moving, you can use TweenService. Here's an example and what you should do :
local TweenService = game:GetService('TweenService')
local Part = script.Parent
local tweenInfo = TweenInfo.new(
2,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false,
0
)
local tween = TweenService:Create(Part, tweenInfo, {Orientation = Vector3.new(0, 180, 0)})
tween:Play()
This is how your whole code might look, with tween :
local model = game.Workspace.Model
local TweenService = game:GetService('TweenService')
for name, child in pairs(model:GetChildren()) do
if child:IsA("MeshPart") then
local container = {
Vector3.new(0,180,0),
Vector3.new(0,-180,0)
}
local tweenInfo = TweenInfo.new(
1,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false,
0
)
local Orientationn = container[math.random(1, #container)]
local tween = TweenService:Create(Part, tweenInfo, {Orientation = Orientationn})
tween:Play()
end
end
Note : That the tween will play one by one, as the parts will be inspected one by one. If you want all of it to happen all at once, I'll edit the code and give explanation to it.
Lemme know if it helps!