This code is supposed to go through every value in the table and assign it a random number from 0 to 50 (The minimum was set to 1 for testing reasons).
local function Init()
local p = script.Parent:GetChildren()
for i, v in ipairs(p) do
if p[i].Name == "Part" then
parts[i] = p[i]
local value = Instance.new("NumberValue")
value.Parent = p[i]
value.Value = math.random(1, 50)
value.Value = states[i]
print(p[i].Name..i.." has the value of "..p[i].Value.Value)
end
end
end
However, the values are being instantiated, but are not being assigned with the random number. The output looks like this
Part1 has the value of 0
Part2 has the value of 0
Part3 has the value of 0
Part4 has the value of 0
Part5 has the value of 0
Part6 has the value of 0
Part7 has the value of 0
Part8 has the value of 0
Part9 has the value of 0
Part10 has the value of 0
Part11 has the value of 0
Part12 has the value of 0
Part13 has the value of 0
Part14 has the value of 0
Part15 has the value of 0
Part16 has the value of 0
Part17 has the value of 0
Part18 has the value of 0
Part19 has the value of 0
Part20 has the value of 0
Part21 has the value of 0
Part22 has the value of 0
Part23 has the value of 0
Part24 has the value of 0
It worked before, but I have no idea why it just broke today.

1 comment
Oops.