In my RPG Game, whenever you level up your health is increased;
function onLevelUp(player, XP, level) wait(0.1) player.Character.Humanoid.Health = player.leaderstats.PwrLvl.Value * 100 + 100 player.Character.Humanoid.MaxHealth = player.leaderstats.PwrLvl.Value * 100 + 100
But when you die your maxhealth that you earned goes away. But when you respawn it saves al except MaxHealth your other stats that I implemented.
If you read this can you help me make a script that increases your maxhealth like shown when you respawn? Thanks. -jm34
You could use game.StarterPlayer.StarterHumanoid.MaxHealth = 250
source: http://wiki.roblox.com/index.php?title=API:Class/StarterPlayer
A good way to do this would be to put a NumberValue
in the player that will save the MaxHealth
. Then, whenever the player's character is respawned, you can set the Humanoid
's MaxHealth
to the Value
of that NumberValue
. You can use the CharacterAdded method for this:
assuming that you have a variable called player that points to the player and that you've already created the NumberValue StoredMaxHealth
player.CharacterAdded:connect(function(char) char.Humanoid.MaxHealth = player.StoredMaxHealth.Value; end);