local MusicScript = workspace.MusicScript
local MusicScript2 = workspace.MusicScript2
local circles = script.Parent:GetChildren()
local circles = {workspace["Map Circles"]["Meshes/TrueRingMesh"]
}
while true do
if MusicScript.Enabled == true then
for i = 1, #circles do
local circle = circles[i]
circles.BrickColor = Color3.new(0, 0.0509804, 1)
end
task.wait()
end
if MusicScript2.Enabled == true then
for i = 1, #circles do
local circle = circles[i]
circles.BrickColor = Color3.new(1, 1, 1)
end
task.wait()
end
end
Here is the current issue; While when I put print() statements in the if statements, which they do print out, the parts do not change color and it most likely has to do something with circles and that I don’t know how to get all of the Map Circles (a folder containing the circles) circles to change all their colors by knowing how to declare a variable that tracks all the circles in the folder, which I don’t know how to do that and I am asking for help on how to do that, and help debug the script incase I am doing things wrong, which include my first attempt at making a dictionary or the for i = 1, #circles do and local circle = circles[i] so the script works. I’d appreciate the help for debugging the script!
You have circles declared twice which isn’t good, it will likely only use the last declaration which is
local circles = {workspace["Map Circles"]["Meshes/TrueRingMesh"]}
This doesn’t retrieve all children of Meshes/TrueRingMesh, it would help to attach a screenshot of your explorer so we know where the parts you are trying to change live.
I think you want this for your circles declaration
local circles = workspace["Map Circles"]["Meshes/TrueRingMesh"]:GetChildren()
To use an array or dictionary it’s better to use a range-based for loop like so
for index, value in circles do
-- index == i
-- value == local circle = circles[i]
end
It’s good to type check children, so your full script may look like this
local MusicScript = workspace.MusicScript
local MusicScript2 = workspace.MusicScript2
local circles = workspace["Map Circles"]["Meshes/TrueRingMesh"]:GetChildren()
while true do
if MusicScript.Enabled == true then
for index, circle in circles do
if circle:IsA("Part") then
circle.BrickColor = Color3.new(0, 0.0509804, 1)
end
end
task.wait()
elseif MusicScript.Enabled == true then
for index, circle in circles do
if circle:IsA("Part") then
circle.BrickColor = Color3.new(1, 1, 1)
end
end
task.wait()
end
-- might need a task.wait in case neither script is active
task.wait()
end
I’ve tried the solution. I ran the game and when the 2nd script was enabled, none of the circles changed colors nor printed a error in the output. I’m not sure what is causing this not to happen when the scripts being enabled changes and that there is no error being shown in the output.
Now, I can’t show the full image since there is 86 Meshes/TrueRingMesh however this is the order. Folder to Script and then the meshes. The folder is in workspace obviously.
Even when I tried that, the same thing happened. Though it does help with reducing some lines of code. When I ran the game, circles didn’t change color even when the 2nd script was enabled. I don’t know if it has to do with the meshes or not but they definitely can be changed by the color and I’m not sure what’s causing it to not change color or not print out a error.