So I am trying to make a HealthBar according to the player's Health. And I made this script, but its not working for some reason. Any help? --HealthBar script
local Player = game.Players.LocalPlayer
local PlayerHealth = Player.Character:WaitForChild("Humanoid").Health
game.Players.PlayerAdded:Connect(function()
while true do
wait()
local Health = PlayerHealth
local MaxHealth = Player.leaderstats.MaxHealth
local math = ( Health / MaxHealth )
script.Parent:TweenSize(UDim2.new(math,0,1,0),"Out","Quad",.25)
end
end)
--MaxHealth script
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("IntValue", player)
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local MaxHealth = Instance.new("IntValue", leaderstats)
MaxHealth.Name = "Max Health"
MaxHealth.Value = 100
end)

2 comments
Line 07 should be changed to: local Health = Player.Character:WaitForChild("Humanoid").Health
Still not working. :C