Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 7 years ago
Edited 7 years ago

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


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. LightningfireNinja 15 — 7y

2 answers

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

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

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? disneyxdbernstein 6 — 7y
Ad
Log in to vote
0
Answered by 7 years ago

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

Answer this question