game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Health, false) local player = game.Players.LocalPlayer repeat wait() until player.Character local Humanoid = player.Character:WaitForChild("Humanoid") local HealthMath = Humanoid.Health / (Humanoid.MaxHealth) script.Parent:TweenSize(UDim2.new(HealthMath, 0, 1, 0), "Out", "Sine", .5) Humanoid.HealthChanged:connect(function() local HealthMath = Humanoid.Health / (Humanoid.MaxHealth) script.Parent:TweenSize(UDim2.new(HealthMath, 0, 1, 0), "Out", "Sine", .5) end)
So when I take a slightly damage .. The gui overlay do decreases but when it is instant damage the gui overlay just stuck at the previous health. For example , current health now is 100 and took 50 damage then the gui overlay decreases to 50 but when it take sudden/instant death for example by a rocket or explosion current health now 0 but the gui still showing 50.
Local script Put the local script inside a frame.
wait() local Player = game:GetService'Players'.LocalPlayer local Character = Player.Character or Player.CharacterAdded:wait() local Human = Character:WaitForChild("Humanoid") local HealthFrame = script.Parent Human.HealthChanged:connect(function(Health) HealthFrame.Size = UDim2.new(Health/Human.MaxHealth,0,1,0) end)
Here is a Pic http://imgur.com/TdqTxfv
Use a repeat function to get the player's max health and health. Have it update every 0.05 seconds. That way it will update it.