so im trying to make a script which increased/decreases players fov based on songs volume.
1 | local cam = workspace.CurrentCamera |
2 | local sound = workspace.Song |
3 | if sound.IsPlaying = = true then |
4 | while true do |
5 | wait() |
6 | cam.FieldOfView = 70 + (sound.PlaybackLoudness / 50 ) |
7 | end |
8 | end |
is there any way to make it work or make it better? also its a local script but thats not the matter.
I'm not sure if this will be the exact solution to your problem, but while true do will cause a Game script timeout. Do this:
1 | local cam = workspace.CurrentCamera |
2 | local sound = workspace.Song |
3 | if sound.IsPlaying = = true then |
4 | while **wait()** do |
5 | wait() |
6 | cam.FieldOfView = 70 + (sound.PlaybackLoudness / 50 ) |
7 | end |
8 | end |
While wait() do runs the script so that it won't execute too fast. Also don't put a number in the parenthesis.