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.
What is the issue?
The player dies after resetting. And I don’t want that to happen.
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)
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.
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
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)