I made stats like stamina, mana, etc. the max stamina and max mana worked perfectly, whenever you added a stat point, the max went up, but for some reason, It doesn't change the humanoid's max health, it doesn't show any errors or anything, it just does nothing to the humanoid health.
Script:
local player = game.Players.LocalPlayer local health = player:WaitForChild("Stats"):WaitForChild("Health") local playerhealth = player.Character:WaitForChild("Humanoid").Health local maxhealth = player.Character:WaitForChild("Humanoid").MaxHealth local stats = player:WaitForChild("Stats") local expmax = stats:WaitForChild("ExpMax") local level = stats:WaitForChild("Level") local stamina = stats:WaitForChild("Stamina") local maxstam = stats:WaitForChild("MaxStam") local stamstat = stats:WaitForChild("StaminaStat") local durability = stats:WaitForChild("Durability") local magic = stats:WaitForChild("Magic") local maxmana = stats:WaitForChild("MaxMana") while wait(0.01) do health.Value = playerhealth expmax.Value = level.Value * 100 maxstam.Value = stamstat.Value*2 + 100 maxmana.Value = magic.Value*2 + 100 maxhealth = durability.Value*2 + 100 end
I've tried simply putting the durability part in another script, but it still does the same thing, if you have any idea what's wrong, please let me know, because I need this to work for my friends game. Once again, it doesn't show any errors, warnings, etc. so I have no clue where to start.
First of all, MaxHealth
is a property of the humanoid. So at line 4 you set maxhealth
to whatever the humanoid's MaxHealth
currently is (probably 100). Then in the loop you change maxhealth
to another number. This is a common mistake.
If you want to change the value of the humanoid's MaxHealth
, you should do something like this:
local humanoid = player.Character:WaitForChild("Humanoid") -- (removed not relevant code) humanoid.MaxHealth = durability.Value*2 + 100
Another issue: you can't modify anything in the workspace from a LocalScript. It will not replicate to the server. If you need a tutorial on client-server comunication, see this.