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

How would I add sound to this?

Asked by 10 years ago

When ever you take damage, such as if it's more than 50, it'll play a sound, and if it's below 50, it'll play a sound and if it's below 20, it plays a sound?

local self = script.Parent
local Humanoid = self:WaitForChild("Humanoid")
local Regen = false
Humanoid.HealthChanged:connect(function()
    if (not Regen and Humanoid.Health > 0) then
        Regen = false
        while (Humanoid.MaxHealth > Humanoid.Health) do
            local NewHealth = Humanoid.Health + (Humanoid.Health/Humanoid.MaxHealth) + 0.5
            Humanoid.Health = NewHealth
            wait(Humanoid.Health/Humanoid.MaxHealth * 0.00001)
        end
        if (Humanoid.MaxHealth < Humanoid.Health) then
            Humanoid.Health = Humanoid.MaxHealth
        end
        Regen = false
    end
end)

1 answer

Log in to vote
0
Answered by
OniiCh_n 410 Moderation Voter
10 years ago

Add more if statements! Although, I don't know what you're really asking for with the more than 50 and all that.

0
Like, in Serious Sam. If you take a lot of damage your guy will go "OOOOHHHHH!!!!" or something like that. lol TheRings0fSaturn 28 — 10y
0
More. If. Statements. OniiCh_n 410 — 10y
Ad

Answer this question