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

How do I check for a certain Health amount?

Asked by
TofuBytes 500 Moderation Voter
10 years ago

This script is located inside the Humanoid of a model. I'm trying to detect the health if it's less than or equal 200 then it plays a warning sound. Help?

local H = script.Parent.Health
local Warning = game.Workspace.Warning

while true do
if H <= 200 then
    Warning:Play()
end
if H > 200 then
    Warning:Stop()
end
wait()
end

1 answer

Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
10 years ago
local H = script.Parent.Health
local Warning = game.Workspace.Warning

while H <= 200 do
wait()
    if not Warning.IsPlaying == true then
        Warning:Play()
    end
end

while H > 200 do
wait()
if Warnin.IsPlaying == true then
    Warning:Stop()
end
end

~Thank me by accepting this answer/bumping up my reputation!

0
Seems to freeze the game when testing. TofuBytes 500 — 10y
0
Try now. Shawnyg 4330 — 10y
Ad

Answer this question