Hi.
I have experienced the error in the title But it has a PointLight. It keeps registering it's not there.
Here is my code.
function gen.flicker(lightP) local info = TweenInfo.new(0.2, Enum.EasingStyle.Elastic, Enum.EasingDirection.InOut, 1, false) local on = gen.tweenServ:Create(lightP.PointLight, info, {Brightness = 1}) local off = gen.tweenServ:Create(lightP.PointLight, info, {Brightness = 0}) off:Play() off.Completed:Wait() lightP.Material = 'Glass' on:Play() on.Completed:Wait() lightP.Material = 'Neon' off:Play() off.Completed:Wait() lightP.Material = 'Glass' on:Play() on.Completed:Wait() lightP.Material = 'Neon' off:Play() off.Completed:Wait() lightP.Material = 'Glass' on:Play() on.Completed:Wait() lightP.Material = 'Neon' end function gen.blackout(room) local lamps = room.Assets.Lamps:GetChildren() for _, lamp in ipairs(lamps) do for _, obj in ipairs(lamp:GetChildren()) do if obj.Name == 'Shade' then task.spawn(function() gen.flicker(obj) end) end end end end
Maybe you either changed the name of it or you're using it in the Client. Try using :FindFirstChildOfClass()
or :FindFirstChildWhichIsA()
which searches for a child that has the same class name in the given argument regardless of its name. If you're using it in the Client, try making a custom waitForChildWhichIsA()
function.
local function waitForChildWhichIsA(parent, className) local child repeat task.wait() child = parent:FindFirstChildWhichIsA(className) until child ~= nil return child end function gen.flicker(lightP) local PointLight = waitForChildWhichIsA(lightP, "PointLight") local info = TweenInfo.new(0.2, Enum.EasingStyle.Elastic, Enum.EasingDirection.InOut, 1, false) local on = gen.tweenServ:Create(PointLight, info, {Brightness = 1}) local off = gen.tweenServ:Create(PointLight, info, {Brightness = 0}) off:Play() off.Completed:Wait() lightP.Material = Enum.Material.Glass on:Play() on.Completed:Wait() lightP.Material = Enum.Material.Neon off:Play() off.Completed:Wait() lightP.Material = Enum.Material.Glass on:Play() on.Completed:Wait() lightP.Material = Enum.Material.Neon off:Play() off.Completed:Wait() lightP.Material = Enum.Material.Glass on:Play() on.Completed:Wait() lightP.Material = Enum.Material.Neon end function gen.blackout(room) local lamps = room:WaitForChild("Assets").Lamps:GetChildren() for _, lamp in ipairs(lamps) do for _, obj in ipairs(lamp:GetChildren()) do if obj.Name == "Shade" then task.spawn(function() gen.flicker(obj) end) end end end end