I need to find a way to make a light that blinks Really Black to orange every so often, but if i do it in the script, it will pause the script to run it. How do i get around this?
If I understand your question correctly, I'm assuming you want to have a function that will change the colour of a part to simulate a blinking light if you want it to not affect the timing of that script you're going to want to run it in a different thread so you can continue on with normal tasks.
There are 2 ways you can do this.
Both of them do different things. I recommend reading them both to try to accustom it to your idea. Good luck!
There is a built in function that Roblox adds called spawn. It creates a new thread that runs separately from the other code in the script.
Basic usage would look like
spawn(function() while true do wait() print(5) end end) while true do wait() print(6) end
This would constantly print out 5 and 6 together.
Instead of creating new threads as other answers suggest, you should instead put the code after your light blinking code before your light blinking code, such as turning
blinkLights() doStuff()
to
doStuff() blinkLights()
You should avoid creating threads that you can avoid so the thread manager has less threads to handle. If you have another infinite loop afterwards such as
while true do wait(1) doStuff() end while true do wait(1) doOtherStuff() end
you can combine them to one loop, like so
while true do wait(1) doStuff() doOtherStuff() end
If they have different wait times, you can turn something like
while true do wait(1) doStuff() end while true do wait(3) doOtherStuff() end
to
local iteration = 1 while true do doStuff() if iteration == 3 then doOtherStuff() iteration = 1 else iteration = iteration + 1 end wait(1) end
This will help your code avoid creating a lot of unneeded threads, creating a more performant script and cleaner code.