I am making an explosion shake that changes based on playbackloudness using camera offset, it essentially checks when the explosion sound is added as a descendant of workspace and then starts changing the camera offset (well its supposed to). The problem is it works fine with workspace.Camera but I cant get it to work with CameraOffset, does anyone know why? Here is the code:
wait()
local player = game:GetService("Players").LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local function onDescendantAdded(desc)
if desc:IsA("Sound") then
if desc.Name == "Explode" then
print("Found Sound!")
game:GetService("RunService").RenderStepped:connect(function()
local Sound = desc
hum.CameraOffset = Vector3.new(0,Sound.PlaybackLoudness * 5,Sound.PlaybackLoudness * 5)
end)
end
end
end
game.Workspace.DescendantAdded:Connect(onDescendantAdded)