Hello, im making a health system and need help with health saving if player dies:
- Currently if I reset character it gives me that warning:
RunService:UnbindFromRenderStep removed different functions with same reference name utility-focus-state-inspect-abkolia228 2 times.
I change Humanoid maxHealth and health in localscript and saving this with profile service on server script
-- Local
local PlayerHp = player:WaitForChild('PlayerValues'):WaitForChild('PlayerHp')
local Character = player.Character
local Humanoid = Character:WaitForChild('Humanoid')
local NewHealth = PlayerHp.Value
local HealthBeforeDeath
if Humanoid then
Humanoid.MaxHealth = NewHealth
Humanoid.Health = NewHealth
print(Humanoid.Health)
print(Humanoid.MaxHealth)
end
Humanoid.Died:Connect(function()
HealthBeforeDeath = NewHealth
end)
player.CharacterAdded:Connect(function(character)
Humanoid.MaxHealth = HealthBeforeDeath
Humanoid.Health = HealthBeforeDeath
end)
-- Server
game.Players.PlayerAdded:Connect(function(player)
local profile = dataManager.Profiles[player]
if not profile then return end
profile.Data.PlayerHp = player.PlayerValues.PlayerHp.Value
print(profile.Data.PlayerHp
end)