Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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.

2 comments

0

What you want to make it better?

0

no i mean fix the script

1 answer

✓ Accepted answer

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.

6 comments

0

Also, if it's a localscript, put it in Starterpack or StarterGUI

0

why is wait between ** **

0

oh just removed them and works

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

0

oh ok, thanks have nice day too!

0

:)

This discussion is preserved as it was. New answers, comments, and votes are closed.