Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Attempting to make a muffled sound on low hp effect, can someone tell me what the issue is?

Asked by 2 years ago
Edited 2 years ago

Im trying to make a muffle effect for sounds when on low on hp, it kinda works but it always goes down to -80 no matter how much damage you take!

local Player = game.Players.LocalPlayer
repeat wait() until Player.Character ~= nil
local Humanoid = Player.Character:WaitForChild("Humanoid")

local MaxHealth = Humanoid.MaxHealth

local newHealth = Humanoid.Health

Humanoid:GetPropertyChangedSignal("Health"):Connect(function()
    if newHealth > Humanoid.Health then
        for i, v in pairs(game.Workspace.Music:GetChildren()) do
            game:GetService("TweenService"):Create(v.EqualizerSoundEffect, TweenInfo.new(1.5), {HighGain = -(Humanoid.Health/Humanoid.MaxHealth * 500), MidGain = -(Humanoid.Health/Humanoid.MaxHealth * 500) }):Play()
        end
    elseif newHealth < Humanoid.Health then
        for i, v in pairs(game.Workspace.Music:GetChildren()) do
            game:GetService("TweenService"):Create(v.EqualizerSoundEffect, TweenInfo.new(1.5), {HighGain = (Humanoid.Health/Humanoid.MaxHealth / 500), MidGain = (Humanoid.Health/Humanoid.MaxHealth / 500) }):Play()
        end
    end 
    newHealth = Humanoid.Health
end)

this is my script that im using.

Answer this question