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

Why does this script crash my roblox studio?

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

✓ Accepted answer

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

3 comments

0

If this helped you anyway at all please press the "Accept Answer" button under my Characters image

0

Umm. So the for this is also a loop? So if I do for i = 1, 20 do wait(0.06) (script) end

0

Yes but it'll only loop 20 times

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

2 comments

0

I put wait() at the end...

0

Slow it down, the speed is probably doing you in. wait() only slows it by like 0.25 seconds

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