for i = 1, 80, 0.1 do script.Parent.SpotLight.Angle = i print(script.Parent.SpotLight.Angle) I kept adding 0s to 0.1 but it would freeze up the game. I want people to be able to see how the light lights up the room like in real life.
✓ ANSWER ACCEPTED
Are you able or how can you slow down the speed of a for loop?
1 answer
✓ Accepted answer
It is simple to slow down any type of loop. Just add a wait() in it.
For Loop:
for i = 1, 10 do
wait(1) -- Would print from 1 to 10 every 1 second.
print(i)
end
Repeat Loop:
repeat
wait(0.5)
print("Hello, world")
until 5 > 100
While Loop:
while true do
wait(1)
print("Hello.")
end
That is how it's done.
Remember for the while loop, don't do while wait(1) do. As it is deprecated.
4 comments
0
Also, the reason the game might crash is because you don't have a wait(). You need a wait() in every loop to slow it down. Or something like game:GetService("RunService").Stepped:Wait()
0
@suspectshot108 it is not deprecated (yet, as of now)
0
I also suggest adding a wait() without a value so it will run smoother
0
It is deprecated as of now and a long time ago lol
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Add a call to wait in the body. wait(0.1) will cause the script to wait about a tenth of a second.
incapaz stop, ur too intelligent for this site ;(