So i made a script that is supposed to upgrade your max health but i tried making it so it saves even after your death But the script didnt work Here is the script:
local player = game.Players.LocalPlayer local leaderstats = player:WaitForChild("leaderstats") local respawnTime = 3 player.CharacterAdded:Connect(function(char) local humanoid = char:WaitForChild("Humanoid") if humanoid then humanoid.Died:Connect(function() wait(respawnTime) player.Character.Humanoid.MaxHealth = leaderstats.MaxHealth.Value player.Character.Humanoid.Health = leaderstats.MaxHealth.Value end) end end)
Well, a few things here.
Died
event on the humanoid in order to re-assign the max health. You should just be able to wait for the character to respawn, then change the max health.Here is an implementation of this inside of a server script:
local Players = game:GetService("Players"); -- some default max health you want to assign local DEFAULT_MAX_HEALTH = 500; local onPlayerAdded = function(newPlayer) newPlayer.CharacterAdded:Connect(function(char) local humanoid = char:WaitForChild("Humanoid") -- update the humanoid's health/max health humanoid.MaxHealth = DEFAULT_MAX_HEALTH; humanoid.Health = humanoid.MaxHealth; end)) end Players.PlayerAdded:Connect(onPlayerAdded);
Let me know if you have any questions