use this
for i = 1, #light do
end
befor the last end to add other loop
use this
for i = 1, #light do
end
befor the last end to add other loop
OK, I missed the spawn function in first read through. This wasn’t really 61 lines, as you put multiple lines on one row. I made a few changes:
I think the errors you are seeing are due to unclear wait times. This makes that all transparent. Might even reproduce the error, as I tried to reproduce the script as close as possible.
--[[local lightDelay = {
Can define delays here, but its a pattern so I used a formula.
["Ta1"] = 0.01, ["Ta24"] = 0.01,
["Ta2"] = 0.02, ["Ta23"] = 0.02,
["Ta3"] = 0.03, ["Ta22"] = 0.03,
["Ta4"] = 0.04, ["Ta21"] = 0.04,
etc
}]]
local lightDelay = {}
function fader(i, v)
wait(.01)
v.Head.Beam.SpotLight.Brightness = 2.5+2.5*i
v.Head.Lens.Transparency = .75-.25*i
v.Head.Beam.light.Transparency = NumberSequence.new(.75-.25*i)
end
function Fade_In(v)
v.Head.Lens.Transparency = _G.EFFECT_DIMMER
v.Head.Beam.light.Transparency = NumberSequence.new(_G.EFFECT_DIMMER)
v.Head.Beam.SpotLight.Brightness = _G.EFFECT_DIMMER
for i = 1,3 do fader(i, v) end
end
function Fade_Out(v)
for i = 3,1,-1 do fader(i,v) end
v.Head.Lens.Transparency = _G.EFFECT_DIMMER
v.Head.Beam.light.Transparency = NumberSequence.new(_G.EFFECT_DIMMER)
v.Head.Beam.SpotLight.Brightness = _G.EFFECT_DIMMER
end
for i,v in ipairs(game:GetService("Workspace").TaLights:GetChildren()) do
if i <= 12 then
lightDelay[i] = i * .01
else
lightDelay[i] = .25 - i * .01
end
coroutine.wrap(function()
wait(lightDelay[i])
while wait() do
Fade_In(v)
wait(.12)
Fade_Out(v)
wait(.12)
end
end) ()
end
I found a couple errors and fixed them, if you are running into issues. I should add, this is a very fast blink, around 3 times per second by my count. This is likely to cause stress to photosensitive players, so you may want to throttle it a little.
Sorry for the extreme long response.
I’m going to test this out now.
Bare with me for a few minutes.
Script does not work.
Upon activating the script, the beams don’t turn on and script refuses to do absolutely anything. I’ve checked output and no error has been given out.
If there are no errors, then it’s probably not finding any children. The Fade functions would definitely spit out errors if there were naming issues.
Is this in a local or regular script? That will affect what the script sees.
And maybe add these 2 lines before the for loop, just to see how many lights it finds. I suspect it’s zero, but maybe the children haven’t loaded? Throwing in a wait(1) might make things start working too.
local loopTest = game:GetService("Workspace").TaLights:GetChildren()
print(#loopTest)
My script is a serverscript, no local script.
Let me test this one out
The Looptest does not print anything out, meanwhile the script is also activated.
not printing anything is itself a bug report lol
where are you putting the script? can you screenshot its location and setup? Did you try adding a wait (though a wait would probably not fix the “not printing”)?
This is the location of the script.
Activator script is to actually enable the Loop Script (where the code is) per MouseButton1Click function.
By setup, I suppose the actual instances? If not… I don’t know but here you go.
TaLights and TechnicaPannel are both inside of Workspace.
Try enabling the script from the start? Reduce the variables.
The error might be in the activation.
Script is enabled from the start and nothing is happening. No error, nothing.
If the print is right here, and it doesn’t print, the script probably isn’t running at all. I can get my coroutines not working, but a print? Nah, something is wrong. I’m not seeing it though.
You can confirm that the script never runs with a “Hello World” as the very first line. Maybe check the server while the game is running to make sure nothing gets deleted.
There’s no print(“Hello World”) in the script though.
The instances also don’t delete because I’ve checked it before, while running the game.
Just add the line. It doesn’t add or harm anything. You are looking for a new bug.
If you can establish that the code does not run, the problem exists outside the code and we can stop looking there,
Ok, stupid me put the Looptest function in the wrong line.
I managed to print out the amount of Instances
Because I instead thought of the for loops inside of function Fade_Out/In(v)
Although it prints out the children, but the actual script does not run (Fade In effect).
EDIT: After the printing, the code stops.
ok, that means the problem is my loop I will remove the lighting part of the code and see what I messed up.
BTW 49 children? That means you have things in there that are not lights. I was assuming that the folder only had the 24 lights. My formula for lightdelay will not work. That’s fixable, but the loop needs to run first.
Oh… yeah… 49 children, why? I duplicated the 24 instances (1 of them I accidentally dupliacted 2 times so making that 49 instead of 48) because this system allows you to add as many instances (basically that’s why the GetChildren() part is there), you want, as long as they have the name ranging from Ta1 to Ta24.
If that was not the case, my Handler for the beams and the actual Panel where I store all the effect wouldn’t work.
I think I follow that. It just means LightDelay has to use the table, not a formula. I intended the table for customizing the delay, but it serves a higher purpose now.
So in that case, we could add somewhere, something like this, where it gets all childrens that are named Ta with their numbers?
for i,v in pairs(game:GetService("Workspace").TaLights:GetChildren()) do
local num = tonumber(v.Name:match("Ta(%d+)"))
if num then
-- code here
end
end
Because what I’m thinking is the line
if i <= 12 then
is only looking for half of the instances and not names?