I’m trying to detect if the Humanoid health has changed. Is this correct? Because it hasn’t worked!
local Humanoid = script.Parent.Humanoid
local Health = Humanoid.Health
while true do
wait()
if Health < 100 then
print("I'm hit!")
end
end
I’m trying to detect if the Humanoid health has changed. Is this correct? Because it hasn’t worked!
local Humanoid = script.Parent.Humanoid
local Health = Humanoid.Health
while true do
wait()
if Health < 100 then
print("I'm hit!")
end
end
First:
You can’t assign a Variable to Helath, as it will not change when the Humanoid is hit
Second:
Simply do:
humanoid.Changed:Connect(function()
if humanoid.Health < 100 then
print(“I’m hit!”)
end
end)
(Note that you should be going what @FroDev1002 said)
Another way of doing this is using the propertyChangedSignal event. as so
hum:GetPropertChangedSignal('Health'):Connect(function() -- the health part is the value we detect to see if it changes
-- put your code in here
end
``
That will run every time the players health changes. This can be used to tell if they heal, or take damage!
For more on this:
[LINK](https://devforum.roblox.com/t/changedgetpropertychangedsignal-when-and-how-to-use-them/362082)
Oh my gosh! Thank you all so much!
Mark @FroDev1002‘a post as the solution, it’s better (mine would run everyone something changes in the Humanoid)
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.