In my game, there is a model called OilTanks with several models in it. This script is supposed to get the children of OilTanks, select a random model, and find a UnionOperation named Tank in the randomly selected model.
repeat
wait(1)
c = game.Workspace.OilTanks:GetChildren()
for l = 1, #c do
local b = math.random(1, #c[l].Name) -- chooses a random tank
for i = 1, #b do
if (b[i]:FindFirstChild("Tank") ~= nil) then
print("Success")
wait(3)
script.MaxNumber.Value = script.MaxNumber.Value - 1
wait(5)
wait()
end
end
end
until script.MaxNumber.Value == 0
The problem is that I get an error: "attempt to get length of local 'b' (a number value)" pertaining to "for i = 1, #b do" Also, would it be better if I just named the models to be randomly selected "Model1", "Model2"?
- Workspace
- OilTanks
- Model
- Tank
- Model
- Tank
- Model
- Tank
- Model
- OilTanks

1 comment
What the heck? Who downvoted my question and someone's answer for no reason?