Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

i tried to make a lightning script and i need it to stop looping please help?

hello im new to scripting and im trying to make a script that makes lightning appear and disappear for a quick second but it keeps looping and idk why heres my script

while true do
wait(.1)
script.Parent.Transparency = 1

wait(4.5)
script.Parent.Transparency = 0

wait(.1)
script.Parent.Transparency = 1

end


1 comment

0

"while true do". A while loop will forever repeat until the condition after it is false. You put while true do. true==true ALWAYS.

2 answers

✓ Accepted answer

While true do is a loop.

wait(.1)
script.Parent.Transparency = 1

wait(4.5)
script.Parent.Transparency = 0

wait(.1)
script.Parent.Transparency = 1

that won't loop it.

Note: you say for a quick second? "wait(4.5)" waits 4 and a half seconds

1 comment

0

thx also do you know how to make an audio play after a certain time like so i can make thunder noise a few seconds before the lightning?

this repeats the lightning until a certain moment

local a = 0
repeat
wait(.1)
script.Parent.Transparency = 1     -- so right now, you can't see the lightning

wait(4.5)
script.Parent.Transparency = 0 -- then u wait 4.5 secs before the lightning appears

wait(.5)        -- i changed that so the lightning actually lasts longer
script.Parent.Transparency = 1 -- finally after .5 seconds of lightning, the lightning disappears
a = a + 1
print(a)
until a == 20

^ that will keep changing a by one until it reaches twenty in two minutes and two seconds EXACT it will stop i even added a print(a) so you can keep track of how long it is before it stops

Thanks, by greatneil80

remember to accept this post if it works

This discussion is preserved as it was. New answers, comments, and votes are closed.