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

Why won't this script work? I've been trying for a bit, but I have found no resolve.

Asked by 3 years ago

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
0
the 'random' method of the mathematics class is lowercase; programming languages are case-sensitive. Ziffixture 6913 — 3y
0
Changed the math.Random to math.random, still doesn't work, except there are no longer any errors. IrishRepubIic 9 — 3y

Answer this question