Is there a function to do this? or something?
Set the "Dead" state to false like this:
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Dead, false)
This will disable the character dying once the health reaches 0. I think I made a revive script before and using Character:BreakJoints()
kills them no matter what, can't confirm since it's been a while.
You must disable this or it'll respawn the character once their health reaches 0. You have to create your own respawn system and what not.
Not really, there may be someone who discovered a SUPER hacky way around this but one, its hacky, and two most developers opt for this:
Creating another value that acts as health. e.g a NumberValue located inside the humanoid that acts as Health
but what if i want to do something when they loose all health?
changed event
local health=humanoid.HV health.Changed:Connect(function() if health.Value<=0 then --'died' end end)
How about takedamage?
local health=humanoid.HV function TakeDamage(val) --to keep it between 0 and 100 health.Value=math.clamp(health.Value-val,0,100) end
You could even set this to a BinableEvent
local health=humanoid.HV script.TakeDamage.Event:Connect(function(val) --to keep it between 0 and 100 health.Value=math.clamp(health.Value-val,0,100) end)
HV being the NumberValue
This answer is based on what you mentioned in your comment.
A simple way I can think of doing the Health is to make a NumberValue and change the player's health based on what this number is. If the number is less than 1 then don't change the player's health. Here's a bit of example code.
local function ChangeHP(Player, Amount) if game.Players:GetPlayerFromCharacter(Player) then local Humanoid = Player:FindFirstChild("Humanoid") if Humanoid then local FakeHealth = Humanoid:FindFirstChild("FakeHealth") if FakeHealth then FakeHealth.Value = FakeHealth.Value + Amount if FakeHealth.Value < 1 then print("Player is downed") Humanoid.Health = 1 FakeHealth.Value = 0 else Humanoid.Health = FakeHealth.Value end end end end end game.Players.PlayerAdded:Connect(function(Player) Player.CharacterAdded:Connect(function(Character) local Humanoid = Character:WaitForChild("Humanoid") if Humanoid then local FakeHealth = Instance.new("NumberValue") FakeHealth.Name = "FakeHealth" FakeHealth.Parent = Humanoid FakeHealth.Value = Humanoid.Health end while wait(1) do ChangeHP(Character, -10) end end) end)