The following is a very simple script, but always crashes my game when I test it. Why?
1 | while true do |
2 | script.Parent.SpotLight.Angle = script.Parent.SpotLight.Angle + 5 |
3 | end |
I cannot tell you why, but games always crash when you do not wait before ending a infinite loop. This may be because it's loops an infinite amount of times and it's too much to handle/too fast. To fix this, just add a wait before the end.
1 | while true do |
2 | script.Parent.SpotLight.Angle = script.Parent.SpotLight.Angle + 5 |
3 | wait() --I prefer wait() unless you would like to use wait(1), depending on how fast you want it to add 5 to the angle. |
4 | end |