Hello, I am trying to make it so when a button is clicked, the lights will turn white from the first bar to the last bar. Problem is, the lights won’t go on or become white, and no errors print in the console.
code;
local WaveI = game.Workspace:WaitForChild("WaveA")
local WaveA = {
WaveI:WaitForChild("WaveA"):GetDescendants(),
WaveI:WaitForChild("WaveB"):GetDescendants(),
WaveI:WaitForChild("WaveC"):GetDescendants(),
WaveI:WaitForChild("WaveD"):GetDescendants(),
WaveI:WaitForChild("WaveE"):GetDescendants(),
WaveI:WaitForChild("WaveF"):GetDescendants(),
WaveI:WaitForChild("WaveG"):GetDescendants(),
WaveI:WaitForChild("WaveH"):GetDescendants(),
WaveI:WaitForChild("WaveI"):GetDescendants(),
WaveI:WaitForChild("WaveJ"):GetDescendants(),
WaveI:WaitForChild("WaveJ"):GetDescendants(),
WaveI:WaitForChild("WaveK"):GetDescendants(),
WaveI:WaitForChild("WaveL"):GetDescendants(),
WaveI:WaitForChild("WaveM"):GetDescendants(),
WaveI:WaitForChild("WaveN"):GetDescendants(),
WaveI:WaitForChild("WaveO"):GetDescendants(),
WaveI:WaitForChild("WaveP"):GetDescendants(),
WaveI:WaitForChild("WaveQ"):GetDescendants(),
WaveI:WaitForChild("WaveR"):GetDescendants(),
WaveI:WaitForChild("WaveS"):GetDescendants(),
WaveI:WaitForChild("WaveT"):GetDescendants(),
WaveI:WaitForChild("WaveU"):GetDescendants()
}
script.Parent.MouseClick:Connect(function(plr)
if plr:GetRankInGroup(14407410) >= 200 then
for _,v in ipairs(WaveA) do
if (v.ClassName == "Part") then
v.Color = Color3.fromRGB(255, 255, 255)
task.wait(0.07)
end
end
for _,v in ipairs(WaveA) do
if (v.ClassName == "Part") then
v.Color = Color3.fromRGB(0, 0, 0)
task.wait(0.07)
end
end
end
end)
and yes, I know this code is very unefficient and can be shortened, but with for loops, etc, it will turn on random lights.
What I am trying to achieve;
(each bar turns black from A to B.)
Video of what it looks like that im trying to achieve:
If no errors or warnings (infinite yeild for instance) are shown them I’m betting your player GetRankInGroup check is failling try printing that out. or none of your waves have descendants.
The problem is that these are individual tables, so you would have to go through those too.
local WaveI = game.Workspace:WaitForChild("WaveA")
local WaveA = {
WaveI:WaitForChild("WaveA"):GetDescendants(),
WaveI:WaitForChild("WaveB"):GetDescendants(),
WaveI:WaitForChild("WaveC"):GetDescendants(),
WaveI:WaitForChild("WaveD"):GetDescendants(),
WaveI:WaitForChild("WaveE"):GetDescendants(),
WaveI:WaitForChild("WaveF"):GetDescendants(),
WaveI:WaitForChild("WaveG"):GetDescendants(),
WaveI:WaitForChild("WaveH"):GetDescendants(),
WaveI:WaitForChild("WaveI"):GetDescendants(),
WaveI:WaitForChild("WaveJ"):GetDescendants(),
WaveI:WaitForChild("WaveJ"):GetDescendants(),
WaveI:WaitForChild("WaveK"):GetDescendants(),
WaveI:WaitForChild("WaveL"):GetDescendants(),
WaveI:WaitForChild("WaveM"):GetDescendants(),
WaveI:WaitForChild("WaveN"):GetDescendants(),
WaveI:WaitForChild("WaveO"):GetDescendants(),
WaveI:WaitForChild("WaveP"):GetDescendants(),
WaveI:WaitForChild("WaveQ"):GetDescendants(),
WaveI:WaitForChild("WaveR"):GetDescendants(),
WaveI:WaitForChild("WaveS"):GetDescendants(),
WaveI:WaitForChild("WaveT"):GetDescendants(),
WaveI:WaitForChild("WaveU"):GetDescendants()
}
script.Parent.MouseClick:Connect(function(plr)
if plr:GetRankInGroup(14407410) >= 200 then
for _,tbl in ipairs(WaveA) do
for _,v in ipairs(tbl) do
if (v.ClassName == "Part") then
v.Color = Color3.fromRGB(255, 255, 255)
task.wait(0.07)
end
end
end
for _,tbl in ipairs(WaveA) do
for i,v in pairs(tbl) do
if (v.ClassName == "Part") then
v.Color = Color3.fromRGB(0, 0, 0)
task.wait(0.07)
end
end
end
end
end)
I know, while I was typing the entire table, the quick type thing specifically showed the waves in the WaveA model, and specifically, I also tested this in the command bar, it changed them to white.
I sent the script in my last post already, but to answer this again, you would need to loop over “v”, which would be the table. Although in my script I renamed it to “tbl” so I wouldn’t have to change much code besides adding another for loop.
local WaveI = game.Workspace:WaitForChild("WaveA")
local WaveA = {
WaveI:WaitForChild("WaveA"):GetDescendants(),
WaveI:WaitForChild("WaveB"):GetDescendants(),
WaveI:WaitForChild("WaveC"):GetDescendants(),
WaveI:WaitForChild("WaveD"):GetDescendants(),
WaveI:WaitForChild("WaveE"):GetDescendants(),
WaveI:WaitForChild("WaveF"):GetDescendants(),
WaveI:WaitForChild("WaveG"):GetDescendants(),
WaveI:WaitForChild("WaveH"):GetDescendants(),
WaveI:WaitForChild("WaveI"):GetDescendants(),
WaveI:WaitForChild("WaveJ"):GetDescendants(),
WaveI:WaitForChild("WaveJ"):GetDescendants(),
WaveI:WaitForChild("WaveK"):GetDescendants(),
WaveI:WaitForChild("WaveL"):GetDescendants(),
WaveI:WaitForChild("WaveM"):GetDescendants(),
WaveI:WaitForChild("WaveN"):GetDescendants(),
WaveI:WaitForChild("WaveO"):GetDescendants(),
WaveI:WaitForChild("WaveP"):GetDescendants(),
WaveI:WaitForChild("WaveQ"):GetDescendants(),
WaveI:WaitForChild("WaveR"):GetDescendants(),
WaveI:WaitForChild("WaveS"):GetDescendants(),
WaveI:WaitForChild("WaveT"):GetDescendants(),
WaveI:WaitForChild("WaveU"):GetDescendants()
}
script.Parent.MouseClick:Connect(function(plr)
if plr:GetRankInGroup(14407410) >= 200 then
for _,tbl in ipairs(WaveA) do
for i,v in ipairs(tbl) do
if (v.ClassName == "Part") then
v.Color = Color3.fromRGB(255, 255, 255)
task.wait(0.07)
end
end
end
for _,tbl in ipairs(WaveA) do
for i,v in pairs(tbl) do
if (v.ClassName == "Part") then
v.Color = Color3.fromRGB(0, 0, 0)
task.wait(0.07)
end
end
end
end
end)