So I was applying a rainbow script to a model, since the model had multiple parts that needed the effect I attempted to have a single script control the rainbow on all those parts(This is a local script):
local t = 5; --how long does it take to go through the rainbow
local tick = tick
local fromHSV = Color3.fromHSV
local RunService = game:GetService("RunService")
local Parts = {}
local parent = script.Parent
for index, value in pairs(parent:GetChildren()) do
print(value)
if value.Name == "rainbow" then
Parts[#Parts+1] = value
end
end
RunService:BindToRenderStep("Rainbow", 1000, function()
local hue = tick() % t / t
local color = fromHSV(hue, 0.1, 1)
for index, value in pairs(Parts) do
value.Color = color
end
end)
The problem comes in when the code actually runs, for some reason GetChildren() is only returning the script itself, and no other values. I have confirmed this using the print statement included in the code. If I had to guess this is probably from the script loading in and executing before other parts of the model load on the client, but I am not sure how to prevent this.