local healthtostore = game:GetService("DataStoreService")
local hpStore = healthtostore:GetDataStore("Health")
local plr = game:GetService("Players")
plr.PlayerAdded:connect(function(p)
local default_properties = {
100;
}
local char = p.Character or p.CharacterAdded:wait()
local humanoid = char:WaitForChild("Humanoid")
local data
local succ, err = pcall(function()
data = hpStore:GetAsync(p.UserId)
end)
if succ then
humanoid.MaxHealth = data
print("Successful")
else
humanoid.MaxHealth = default_properties[1]
warn(err)
print("Something went wrong")
end
end)
game.Players.PlayerRemoving:Connect(function(p)
local char = p.Character or p.CharacterAdded:wait()
local humanoid = char:WaitForChild("Humanoid")
local succ, err = pcall(function()
hpStore:SetAsync(p.UserId, humanoid.MaxHealth)
end)
if succ then
print("Saved")
else
print("Error whilst saving the data")
end
end)
COMMUNITY QUESTION
How can I save the humanoids MaxHealth?
0 answers
No public answers were preserved for this question.
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
really the only 2 things i can think is 1) bindtoclose or an extremely rare case where you need to tonumber humanoid.MaxHealth on 38 but you prob dont
well thanks for atleast trying