I've been trying to identify all children within a model, but I'm really incapable and don't want to write each line 24 times, but I may have too as the script doesn't work.

Script:

for i,v in pairs(script.Parent["meter"..math.Random(1,24)]:GetChildren()) do
    if v.Name == "glass" then
        v.Material = Enum.Material.Neon
    end
end

Error:

  18:38:50.082  Workspace.rodvalves.center.redmeters.RedMOff:1: attempt to call a nil value  -  Server - RedMOff:1
  18:38:50.082  Stack Begin  -  Studio
  18:38:50.083  Script 'Workspace.rodvalves.center.redmeters.RedMOff', Line 1  -  Studio - RedMOff:1
  18:38:50.083  Stack End  -  Studio

2 comments

0

the 'random' method of the mathematics class is lowercase; programming languages are case-sensitive.

0

Changed the math.Random to math.random, still doesn't work, except there are no longer any errors.