^ 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
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 player.CharacterAdded:Connect(function(character) local hum = character:FindFirstChild("Humanoid") hum.Health = Endurance.Value hum.MaxHealth = Endurance.Value print(hum.MaxHealth) end) end)
for one, you don't need to use PlayerAdded twice here is the code I edited a bit, try it, and it should work