I'm currently making a kind of wasteland game, and I have a script to make the players screen get redder depending on their health.
while true do script.Parent.ImageTransparency = humanoid.Health / 100 wait() end
I want to make a ear ringing sound get louder depending on how low the players health is, but I'm not sure how to do that.
while true do script.Parent.ImageTransparency = humanoid.Health / 100 script.Parent.Parent.Sound.Volume = humanoid.Health / 100 -- a way to reverse the value??? wait() end
I'm just a bit confused on how to do this.
**EDIT - CONTEXT: ** I want the sound to be silent at full health, but get louder as the players health goes down. I should have added this in first. bruh
If I understand what you are asking, and I think I do, then this should work.
while true do if humanoid.Health > 0 then script.Parent.ImageTransparency = humanoid.Health / 100 if humanoid.Health ~= 100 then script.Parent.Parent.Sound.Volume = 1/(humanoid.Health / 100) else script.Parent.Parent.Sound.Volume = 0 end wait() else print("Unable, health is 0 or lower") script.Parent.ImageTransparency = 0 end end
EDIT: Added check for full health, added check for humanoid.Health at or below 0