a = game.Workspace.Map:GetChildren() script.Parent.Touched:connect(function() if script.Parent.Parent.Touched.Value == 0 then script.Parent.Parent.Touched.Value = 1 wait(25) for index,v in pairs(a) do for i = 1,625 do local s = math.random(2,6) v.Size = Vector3.new(4,s,4) wait(.005) end end end end)
The variable a should work as expected. The model is called Map. The numbervalue thing is a parent of the parent of the script, so that works. I think I'm having trouble with the in pairs part.
You should start by fixing your tabbing so that it is easy to read your code:
a = game.Workspace.Map:GetChildren() script.Parent.Touched:connect(function() if script.Parent.Parent.Touched.Value == 0 then script.Parent.Parent.Touched.Value = 1 wait(25) for index,v in pairs(a) do for i = 1,625 do local s = math.random(2,6) v.Size = Vector3.new(4,s,4) wait(.005) end end end end)
I'm not sure why you are using a IntValue when you could just be using a variable:
numberTouched = 0
...
numberTouched = 1
The minimum amount of time that wait
is allowed to wait is about .034 seconds, which is 7 times slower than the amount you are trying to wait.
Your code attempts to resize each part individually 625 times, then moves onto the next part. Each part would take about a third of a minute, then.
If there are other objects in Map
other than parts (e.g., Scripts, Models), though, you'll have a problem -- because they don't have a Size
property.
You should check that v:IsA("BasePart")
to ensure that v
is in fact something that can be resized.
You should be using better variable names. a
is a bad name for the list of objects in a map. Just say map
or mapChildren
or some other useful variable name.