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

how do you modify every value in an array simultaneously?

Asked by 8 years ago

hello thanks for reading I was wondering if it was possible to modify a numbervalue in all of my parts in the array, for instance:

t = {game.mapstorage.map1:GetChildren()}

all of the children of map1 has numbervalues, is it possible to use

while true do --simultaneously change the value of the numbervalue in all of children wait(5) end

or simply put, how do i represent every single part in an array with one variable that i can play with?

thanks!

1 answer

Log in to vote
0
Answered by 8 years ago

First of all, don't wrap GetChildren in a table. It already returns a table.

local t = game.mapstorage.map1:GetChildren()

for num,obj in ipairs(t) do
    print(obj.NumberValue.Value)
end

This is as instant as it gets.

0
Thanks so much for helping, I was really confused with the pairs, this helped clear it up. PoisonShadow8888 10 — 8y
Ad

Answer this question