I am trying to make a screen shake (Shakes along with the music) settings I had the screen shake work until I added the settings (That would allow you to change how much the screen Zooms out) but when I test The script doesn’t work. No errors. No screen shake.
Here is my script
wait(3)
while true do
local Max = script.Parent.Parent.PlayerGui.OpenSettingGui.Frame.ScreenShake.ScreenShakeValue.Value.Value
script.Parent.Parent.PlayerGui.OpenSettingGui.Frame.ScreenShake.ScreenShakeValue.Value.Value = script.Parent.Parent.PlayerGui.OpenSettingGui.Frame.ScreenShake.ScreenShakeValue.Text
wait(.25)
end
local RunService = game:GetService(“RunService”)
local Music = workspace:WaitForChild(“Sound”)
local CurrentCamera = workspace.CurrentCamera
game:GetService(“RunService”).RenderStepped:connect(function()
local CurrentLoudness = Music.PlaybackLoudness
local Max = script.Parent.Parent.PlayerGui.OpenSettingGui.Frame.ScreenShake.ScreenShakeValue.Value.Value
local FOV = ScreenShakeSettings.CameraMinFOV + (ScreenShakeSettings.CameraMaxFOV - ScreenShakeSettings.CameraMinFOV) * (CurrentLoudness / ScreenShakeSettings.CameraMaxVolume)
if FOV >= 75 then
CurrentCamera.FieldOfView = FOV
else
CurrentCamera.FieldOfView = 75
end
end)
(this is my first time using Dev Forum so I could not get any pictures up
)
Would you mind putting your code in a more readable state using the Code block identifier (IDK what to call it)? You can do that by using tilde key, It looks like this:
wait(3)
while true do
local Max = script.Parent.Parent.PlayerGui.OpenSettingGui.Frame.ScreenShake.ScreenShakeValue.Value.Value
script.Parent.Parent.PlayerGui.OpenSettingGui.Frame.ScreenShake.ScreenShakeValue.Value.Value = script.Parent.Parent.PlayerGui.OpenSettingGui.Frame.ScreenShake.ScreenShakeValue.Text
wait(.25)
end
local RunService = game:GetService(“RunService”)
local Music = workspace:WaitForChild(“Sound”)
local CurrentCamera = workspace.CurrentCamera
local ScreenShakeSettings = {
CameraMinFOV = 70,
CameraMaxFOV = Max,
CameraMaxVolume = 1200
}
game:GetService(“RunService”).RenderStepped:connect(function()
local CurrentLoudness = Music.PlaybackLoudness
local Max = script.Parent.Parent.PlayerGui.OpenSettingGui.Frame.ScreenShake.ScreenShakeValue.Value.Value
local FOV = ScreenShakeSettings.CameraMinFOV + (ScreenShakeSettings.CameraMaxFOV - ScreenShakeSettings.CameraMinFOV) * (CurrentLoudness / ScreenShakeSettings.CameraMaxVolume)
if FOV >= 75 then
CurrentCamera.FieldOfView = FOV
else
CurrentCamera.FieldOfView = 75
end
end)
Wrap your while true do loop in a coroutine so the rest of the code runs.
wait(3)
coroutine.wrap(function()
while true do
local Max = script.Parent.Parent.PlayerGui.OpenSettingGui.Frame.ScreenShake.ScreenShakeValue.Value.Value
script.Parent.Parent.PlayerGui.OpenSettingGui.Frame.ScreenShake.ScreenShakeValue.Value.Value = script.Parent.Parent.PlayerGui.OpenSettingGui.Frame.ScreenShake.ScreenShakeValue.Text
wait(.25)
end
end)()
local RunService = game:GetService("RunService")
local Music = workspace:WaitForChild("Sound")
local CurrentCamera = workspace.CurrentCamera
local ScreenShakeSettings = {
CameraMinFOV = 70,
CameraMaxVolume = 1200
}
RunService.RenderStepped:Connect(function()
local CurrentLoudness = Music.PlaybackLoudness
local Max = script.Parent.Parent.PlayerGui.OpenSettingGui.Frame.ScreenShake.ScreenShakeValue.Value.Value
local FOV = ScreenShakeSettings.CameraMinFOV + (Max - ScreenShakeSettings.CameraMinFOV) * (CurrentLoudness / ScreenShakeSettings.CameraMaxVolume)
if FOV >= 75 then
CurrentCamera.FieldOfView = FOV
else
CurrentCamera.FieldOfView = 75
end
end)