There’s a folder that contains Mini001, Mini002 until Mini232
I used this script provided. But it did not detect anything above 099, so Mini100 just doesnt work properly. any fixes?
local MinIndex = 1
local MaxIndex = 232
local CurrentIn = 0
local Path = script.Parent
for current = MinIndex, MaxIndex do
CurrentIn = CurrentIn + 1
local Names = "Mini000"
if CurrentIn < 10 then
Names = "Mini00"..CurrentIn
else
Names = "Mini0"..CurrentIn
end
local lights = Path[Names].lights
local water = Path[Names].Main.Nozzle.Water
local refill = Path[Names].Main.Nozzle.Refill
water:GetPropertyChangedSignal("Enabled"):Connect(function()
for _, bulb in ipairs(lights:GetChildren()) do
bulb.light.Brightness = 1
bulb.light.Enabled = true
bulb.Material = "Neon"
end
end)
refill:GetPropertyChangedSignal("Enabled"):Connect(function()
for _, bulb in ipairs(lights:GetChildren()) do
bulb.light.Enabled = false
bulb.Material = "Glass"
end
end)
end
That’s because the if statement does not consider 3 digits.
Add an if CurrentIn < 100 then statement to fix this.
elseif CurrentIn < 10 then
Names = "Mini00"..CurrentIn
elseif CurrentIn < 100 then
Names = "Mini0"..CurrentIn
else
Names = "Mini"..CurrentIn
end
There is a simpler way to format this, for your knowledge.
Also, why did you define a name for the for loop variable, and then proceed to use a new variable? Just replace CurrentIn with current, and remove the CurrentIn = CurrentIn + 1 line.
I think that it’s best to remember that you should always try and comment each line or block of code just so you know what it does when you come to changing it.
And welcome, have fun scripting!