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

Why this change fov based on music sound script doesnt work?

Asked by 5 years ago
Edited 5 years ago

so im trying to make a script which increased/decreases players fov based on songs volume.

1local cam = workspace.CurrentCamera
2local sound = workspace.Song
3   if sound.IsPlaying == true then
4    while true do
5        wait()
6       cam.FieldOfView = 70 + (sound.PlaybackLoudness / 50)
7end
8   end

is there any way to make it work or make it better? also its a local script but thats not the matter.

0
What you want to make it better? Xapelize 2658 — 5y
0
no i mean fix the script TFlanigan 86 — 5y

1 answer

Log in to vote
1
Answered by
Arj783 72
5 years ago

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:

1local 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.

0
Also, if it's a localscript, put it in Starterpack or StarterGUI Arj783 72 — 5y
0
why is wait between ** ** TFlanigan 86 — 5y
0
oh just removed them and works TFlanigan 86 — 5y
0
Lol I put them in asterix to show you the difference between your script and mine. Btw Have a great day or night! :D Arj783 72 — 5y
View all comments (2 more)
0
oh ok, thanks have nice day too! TFlanigan 86 — 5y
0
:) Arj783 72 — 5y
Ad

Answer this question