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 4 years ago
Edited 4 years ago

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

local cam = workspace.CurrentCamera
local sound = workspace.Song
   if sound.IsPlaying == true then
    while true do
        wait()
       cam.FieldOfView = 70 + (sound.PlaybackLoudness / 50)
end
   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 — 4y
0
no i mean fix the script TFlanigan 86 — 4y

1 answer

Log in to vote
1
Answered by
Arj783 72
4 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:

local cam = workspace.CurrentCamera
    local sound = workspace.Song
       if sound.IsPlaying == true then
        while **wait()** do
            wait()
           cam.FieldOfView = 70 + (sound.PlaybackLoudness / 50)
    end
       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 — 4y
0
why is wait between ** ** TFlanigan 86 — 4y
0
oh just removed them and works TFlanigan 86 — 4y
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 — 4y
View all comments (2 more)
0
oh ok, thanks have nice day too! TFlanigan 86 — 4y
0
:) Arj783 72 — 4y
Ad

Answer this question