Hey Guys, I am running into a new issue with GetDescendants(). I’ve never had this issue before and I am not sure why this is happening or how to solve it.
What I am trying to accomplish is pretty basic. There are three parts total with the name “LightPart” and using GetDescendants(); I would like to change the color of said parts to red. However, when I run the script, it only changes the color of one part at a time instead of simultaneously. Why? How? Any Soluations?
Same thing occurs when I use GetChildren() aswell.
Here is the script.
local lights = script.Parent.Parent:GetDescendants()
for i, flicker in ipairs(lights) do
if flicker:IsA("BasePart") and flicker.Name == "LightPart" then
flicker.BrickColor = BrickColor.new("Black")
wait(5)
flicker.BrickColor = BrickColor.new("Red")
end
end
Update: So the issue to my first problem was solved. I was told by @Befogs that everytime a part changes color; we wait 5 seconds for the next part to change color. The script was updated to the following.
local lights = script.Parent.Parent:GetDescendants()
for i, flicker in ipairs(lights) do
if flicker:IsA("BasePart") and flicker.Name == "LightPart" then
flicker.BrickColor = BrickColor.new("Black")
end
end
wait(2)
for i, flicker in ipairs(lights) do
if flicker:IsA("BasePart") and flicker.Name == "LightPart" then
flicker.BrickColor = BrickColor.new("Red")
end
end
However, a new issue has occured. All parts are changing to the color white the second the game is being runned. This makes it extremely odd due to the fact that the script is supposed to making the color of the parts red, not white. Again, why? How? Any solutions?