How to make the player not die after they reset or their health is lower than 1?

  1. What do you want to achieve? Keep it simple and clear!

I need to make a phase 2/transformation/2nd life system for my fighting game. And I need the player to not die and not respawn after they reset/health loser than 1.

  1. What is the issue?

The player dies after resetting. And I don’t want that to happen.

  1. What solutions have you tried so far?

I tried using Humanoid.SetStateEnabled(Dead, false) but it didn’t seemed to work properly. I also tried to add health to the player when their health is lower than 1, but they still dies. (note: I don’t want the reset button to be disabled)

Any help will be appreciated. =)

2 Likes

Can you share the script where damage is dealt?

1 Like

You mean the script where it detects when the player’s health is lower than 1?

Because I have alot of scripts that does damage to the player

On all of those scripts what you’ll need to do is check if the damage being dealt would cause the player to die (check their current health) then subtract whatever health from them until they are at 1 hp. Then have some BoolValue which prevents them from being damaged anymore and then perform some animation etc. and change their health back to 100.

If you provide 1 damage script, I’ll show you what I mean.

1 Like
Humanoid.SetStateEnabled(Dead, false)

This wouldn’t work anyway, since it’s set after the player dies but you probably meant:

Humanoid.SetStateEnabled(Enum.HumanoidStateType.Dead, false)
2 Likes

Hmm do you mean like

local damage = 10
local currenthealth = target.Humanoid.Health
local healthafterdamage = currenthealth - damage 

If healthafterdamage <= 1 then
currenthealth = 1
local ff = Instance.new("Forcefield", target) 
ff.Visible = false
-- other stuff
end

Yeah, I was actually thinking of the forcefield too, you’ll just need to adjust it slightly, like this:

local ff = Instance.new("ForceField")
ff.Parent = target
--perform animation or other stuff here
ff:Destroy()

But this is only for the weapon’s damage, how do I make that when the player resets he doesn’t die?

game:GetService("StarterGui"):SetCore("ResetButtonCallback", false)

You could use this to disable the reset button entirely. But if a player wants to reset via the button you should probably allow them to.

1 Like

It has to be a LocalScript and it has to be in StarterGui

local GUIS = game:GetService("GuiService")

local Plr = game:GetService("Players").LocalPlayer

GUIS.MenuOpened:Connect(function()

local hum = Plr.Character:WaitForChild("Humanoid")

hum.Health = math.huge

end)

GUIS.MenuClosed:Connect(function()

local hum = Plr.Character:WaitForChild("Humanoid")

hum.Health = 100

end)
1 Like

It makes so it keeps the health to 100 whenever you are on the roblox menu

1 Like

That’s not what I needed, I need the player to have a 2nd life after they died. Not setting their health to 100.

That would be a unfair bug for my fighting game because the player would just spam the gui to get health.

Ok, I understand. I will try to find other solutions.

Well, if I remember correctly, I also have done that in the past. It’s very simple really.

Humanoid.HealthChanged:Connect(function(NewHealth)
   if NewHealth <= 0 then
      Humanoid.Health = 1;
   end;
end);

So you need to do two things

  1. Humanoid:SetStateEnabled(Enum.HumanoidStateType.Dead, false) – only using LocalScript
  2. Set Humanoid.BreakJointsOnDeath to false – I think it doesn’t matter on which script you do it
    try it out and let me know how it goes

I’ve tried that too, but the player still respawn even when they have 1 health.

OK idk how but I fixed it with a very hacky way

It might seem wierd but it actually works

I just put some remote events and some server scripts in SCS,
and in the scripts I code some very hacky way.

Reply to me if you want the scripts.

2 Likes

Lemme take a look at it. I’m pretty sure there’s a simple way to do it.

In SCS:
local script:

local resetBindable = Instance.new("BindableEvent")
local tool = script.Parent
local players = game.Players
local lp = players.LocalPlayer
local Attack_4 = false
wait(1)
resetBindable.Event:connect(function()
	local c = script.Parent

	if tool.liveint.Value ==0 then
		Attack_4 = true
		Attack_4 = script.live1:InvokeServer(lp)
	

	elseif tool.liveint.Value == 1 then
		Attack_4 = true
		Attack_4 = script.live2:InvokeServer()
	end
end)

game:GetService("StarterGui"):SetCore("ResetButtonCallback", resetBindable)

game.ReplicatedStorage.Remotes.PlayCutscene.OnClientEvent:Connect(function()
	Attack_4 = true
	Attack_4 = script.live1:InvokeServer(lp)
end)

Script inside the local script:

local live1 = script.Parent.live1
live1.OnServerInvoke = function(lp)

	local int = script.Parent.Parent.liveint
	
	int.Value = 1
	local Hm = script.Parent.Parent:WaitForChild("Humanoid")
	Hm.Health = 0.7
	local char = script.Parent.Parent
	local ff = Instance.new("ForceField", char)
	ff.Visible = false
	ff.Parent = char
	game.Debris:AddItem(ff,7)
	local deb = true
	wait(0.1)
	
		Hm.Health = Hm.MaxHealth


end
local live2 = script.Parent.live2
live2.OnServerInvoke = function()
	
	local int = script.Parent.Parent.liveint
	
	int.Value = 2
	local Hm = script.Parent.Parent:WaitForChild("Humanoid")
	Hm.Health = -1
	local deb = true
	


end

Script:

local resetBindable = Instance.new("BindableEvent")
resetBindable.Event:Connect(function()
	local c = script.Parent
	c.Humanoid.Health = 0.2

end)

game:GetService("StarterGui"):SetCore("ResetButtonCallback", resetBindable)

Main Script:

local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")
local Debris = game:GetService("Debris")
local char = script.Parent
--------------------------------------------------------------------------------
local int = char.liveint
local deb = true

local Hum = char:WaitForChild'Humanoid'
Hum.HealthChanged:Connect(function(Health)
	Hum:SetStateEnabled(Enum.HumanoidStateType.Dead, false)
	if Health <= 0.2 or int.Value == 1 and deb == true  then
		local ff = Instance.new("ForceField",char)
		ff.Visible = false
		ff.Parent = char
		game.Debris:AddItem(ff, 7)
		deb = false
                --Other unimportant stuff
		Hum:SetStateEnabled(Enum.HumanoidStateType.Dead, true)

	end
end)
	
3 Likes

what a pro scripter, you can sit in menu to not take damage at all