0

# How do I detect if the players health is 92 or lower?

Asked by 6 months ago

Hi, I am trying to make a blood/gore script for my friend to use, and something's not working. Could you give me any advice?

if script.Parent.Humanoid.Health <= 92 then
script.Parent["Left Leg"].Instance.new("Decal")
script.Parent["Left Leg"].Decal.Texture = "http://www.roblox.com/asset/?id=508050906"
script.Parent["Left Leg"].Decal.Face = Region3int16
end


(The script is supposed to be in StarterCharacterScripts)

0
Does it have a function? like 'Player.Character.Humanoid.Health.Changed:Connect(Function()' Obviously that probably wont work cause i made it out of studio, but my point is, do you have something making it check? Galaxybombboy 117 — 6mo
0
It's formally known as an RBXScriptSignal, or among the CS community, an Event; we bind callbacks to these for preforming actions upon these signals firing. Ziffixture 6785 — 6mo
0
There is an existing signal of Humanoid that matches your criteria: HealthChanged Ziffixture 6785 — 6mo
0
@TTChaos I'm fairly new to scripting, and when I went to configure which side the Decal would be facing, I put in "Front", but then it gave an autocorrection, which was "Region3int16". KneeDeepInTheDoot 4 — 6mo

0
TTChaos 747
6 months ago

Like Ziffixture said, You can use Humanoid.HealthChanged to detect when your health is low

local Humanoid = script.Parent.Humanoid -- Get the humanoid
local GoreDecal -- Localize GoreDecal

Humanoid.HealthChanged:Connect(function(Health)
if Health <= 92 then
-- script.Parent["Left Leg"].Instance.new("Decal") is wrong, replace with
GoreDecal = Instance.new("Decal", script.Parent["Left Leg"]) -- which makes a new decal and sets it
GoreDecal.Texture = "rbxassetid://508050906" -- Use rbxassetid://
GoreDecal.Face = Region3int16
end
end)


But I have one question. Why would you set the decal's face to Region3int16?

0
The parental argument of the Instance constructor was deprecated, the best practice is to set the parent manually after all property modifications. Ziffixture 6785 — 6mo
1
@Ziffixture if you are the admin, can you please guide the javascript scripters to add, that, you comment on someone's question and the asker replies it, the one who sent the comment before will get the notification of it BestCreativeBoy 1395 — 6mo
0
Answered by 6 months ago

Well, the easiest answer for your question is to add a while loop to check the loop in intervals.

while wait() do -- Loops the code 33 times a sec
if script.Parent.Humanoid.Health <= 92 then
script.Parent["Left Leg"].Instance.new("Decal")
script.Parent["Left Leg"].Decal.Texture = "http://www.roblox.com/asset/?id=508050906"
script.Parent["Left Leg"].Decal.Face = Region3int16
end
end


Lemme know if it helps!

0
No. You should know better by now not to do this. Events are there for a reason, so the answer provided an hour ago is already the best answer. SteamG0D 1593 — 6mo