i have been trying to make a localscript where it plays a sound when the hp of the player is low i only have 1 player per server if that helps with anything but here is my current script.
Game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?id=178518020") if game.Players.LocalPlayer.Character.Humanoid.Health <= 35 then Workspace.LowHP:Play() end
i tried making the health a variable to save effort but gave that up after so much defeat.
The issue is that will only happen ONCE when the script is loaded. When the script is loaded, the health is 100, so that is never, ever, run! The solution to your issue can be found here, on the wiki.
To use it, connect the HealthChanged event of your Humanoid to a function:
game.Players.LocalPlayer.Character.Humanoid.HealthChanged:connect(function(health) --health is their current health, so do what you want with it end)
game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?id=178518020") local char=game.Players.LocalPlayer.Character char:WaitForChild("Humanoid") Humanoid.HealthChanged:connect(function() if char.Humanoid.Health <= 35 then script.Parent.LowHP:Play() end end)
Put the sound inside the script, and put the script inside StarterGui. Wola :l