Hi there, my playbackloudness script allows the screen to shake to the audio, however it is too shaky. I am very new to lua. Also, the function inside this script is to be toggled on and off by a button or after the song ends (another script with a music playlist). Things like tweening is way too complicated for me but I do want to use tweening in this script.
local RunService = game:GetService("RunService")
local Button = script.Parent
local musicplayer = workspace.Sound
local CurrentCamera = workspace.CurrentCamera
local ScreenShakeSettings = {
CameraMinFOV = 70,
CameraMaxFOV = 80,
CameraMaxVolume = 1500
}
local connected = false
local function changeCameraShakeState()
if not connected then
game:GetService("RunService"):BindToRenderStep("CurrentTrack", 1, function()
local CurrentLoudness = musicplayer.PlaybackLoudness
local FOV = ScreenShakeSettings.CameraMinFOV + (ScreenShakeSettings.CameraMaxFOV - ScreenShakeSettings.CameraMinFOV) * (CurrentLoudness / ScreenShakeSettings.CameraMaxVolume)
if FOV > 0 and FOV < 130 then
CurrentCamera.FieldOfView = FOV
end
end)
else
RunService:UnbindFromRenderStep("CurrentTrack")
end
connected = not connected
end
Button.MouseButton1Click:Connect(changeCameraShakeState)
If it’s simply giving you numbers that are too big (and thusly shaking the screen too much), you can do some simple math on it (eg halving it, times by 0.75, stuff like that) so the numbers getting fed into the “shake screen” part are a lot smaller and thusly won’t shake as much.
i dont mean the Camera:Interpolate function i mean a manual one
here is what i mean
local rs = game:GetService("RunService")
local function step(a,b,c)
return (b-a)*math.min(c,1);
end;
local shakiness=8;
local cam=workspace.CurrentCamera;
rs.RenderStepped:Connect(function(dt)
cam.FieldOfView+=step(cam.FieldOfView,workspace.Sound.PlaybackLoudness/10+60,dt*shakiness);
end);