^ Title
I'd like to make my Max Health equal to the player's endurance
In the workspace there is a script, script contains as follows:
game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(character)
character.Humanoid.MaxHealth = "What Here?!"
end)
end)
The what here part is what I'd like to change, I'm not sure how to refer to Endurance.Value
In the ServerScriptService there is the system script which currently contains (working code):
game.Players.PlayerAdded:connect(function(Player)
local Data = Instance.new("IntValue",Player)
Data.Name = "Data"
local XP = Instance.new("IntValue",Data)
XP.Name = "XP"
XP.Value = 0
local Level = Instance.new("IntValue",Data)
Level.Name = "Level"
Level.Value = 1
local Strength = Instance.new("IntValue",Data)
Strength.Name = "Strength"
Strength.Value = 1
local Endurance = Instance.new("IntValue",Data)
Endurance.Name = "Endurance"
Endurance.Value = 50
local Agility = Instance.new ("IntValue",Data)
Agility.Name = "Agility"
Agility.Value = 1
game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connnect(function(character)
character.Humanoid.MaxHealth = Endurance
end)
end)
XP.Changed:connect(function() XPChange(Player,XP,Level,Endurance) end)
end)
function XPChange(Player,XP,Level,Endurance)
if XP.Value >= Level.Value*10 + 100 then
XP.Value = 0
Level.Value = Level.Value + 1
Endurance.Value = Endurance.Value + 50
end
end

1 comment
It would be better for you if you just created the IntValues in Explorer in a folder and then called :Clone() on that folder, it can save a lot of lines of code.