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

Why does this script crash my roblox studio?

Asked by 9 years ago

I was messing around with some scripts, and when I tried something with the for i = 1, 20 do stuff, it crashed. the script:

for i = 1, 20 do
script.Parent.BrickColor = BrickColor.new("New Yeller")
wait()
end

while true do
for i = 1, 20 do
script.Parent.BrickColor = BrickColor.new("Lime green")
wait()
end
for i = 1, 20 do
script.Parent.BrickColor = BrickColor.new("New Yeller")
wait()
end

2 answers

Log in to vote
0
Answered by
Prioxis 673 Moderation Voter
9 years ago

If a script usually a Loop (repeat, while true do, until) all need some sort of delay or else the script fires extremely fast and causes the studio to lag up

While true do is honestly useless because even if you do

While true do
wait(1)
--script here

is easily replaced by

While wait(1) do
--script here

clears up code and works way better

0
If this helped you anyway at all please press the "Accept Answer" button under my Characters image Prioxis 673 — 9y
0
Umm. So the for this is also a loop? So if I do for i = 1, 20 do wait(0.06) (script) end Operation_Meme 890 — 9y
0
Yes but it'll only loop 20 times Prioxis 673 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

remove the"while true do". Add a delay there, such as while wait(0.6).

0
I put wait() at the end... Operation_Meme 890 — 9y
0
Slow it down, the speed is probably doing you in. wait() only slows it by like 0.25 seconds dudemanloserr 15 — 9y

Answer this question