Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local StarterGui = game:GetService("StarterGui")
- StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Health, false)
- local TweenService = game:GetService("TweenService")
- local Player = game.Players.LocalPlayer
- local Humanoid = Player.Character:WaitForChild("Humanoid")
- local Healthbar = script.Parent
- local Background = Healthbar.Background
- local Trail = Background.Trail
- local Green = Background.Trail.Green
- local TextLabel = Background.TextLabel
- local PreviousHealth = Humanoid.Health
- local Heart = Background.img_Heart
- local Count = 4
- TextLabel.Text = Humanoid.Health.." / "..Humanoid.MaxHealth
- Background.Visible = true
- Green.Visible = true
- Trail.Visible = true
- Heart.Visible = true
- TextLabel.Visible = true
- TweenService:Create(Background, TweenInfo.new(.25, Enum.EasingStyle.Quint), {BackgroundTransparency = .7}):Play()
- TweenService:Create(Green, TweenInfo.new(.25, Enum.EasingStyle.Quint), {BackgroundTransparency = 0}):Play()
- TweenService:Create(Trail, TweenInfo.new(.25, Enum.EasingStyle.Quint), {BackgroundTransparency = 0}):Play()
- TweenService:Create(Heart, TweenInfo.new(.25, Enum.EasingStyle.Quint), {ImageTransparency = 0}):Play()
- TweenService:Create(TextLabel, TweenInfo.new(.25, Enum.EasingStyle.Quint), {TextTransparency = 0}):Play()
- Humanoid.HealthChanged:Connect(function()
- if Humanoid.Health>=PreviousHealth*1.1 or Humanoid.Health<=PreviousHealth*.99 or Humanoid.Health<Humanoid.MaxHealth*.75 then
- Count = 4
- TweenService:Create(Background, TweenInfo.new(.25, Enum.EasingStyle.Quint), {BackgroundTransparency = .7}):Play()
- TweenService:Create(Green, TweenInfo.new(.25, Enum.EasingStyle.Quint), {BackgroundTransparency = 0}):Play()
- TweenService:Create(Trail, TweenInfo.new(.25, Enum.EasingStyle.Quint), {BackgroundTransparency = 0}):Play()
- TweenService:Create(Heart, TweenInfo.new(.25, Enum.EasingStyle.Quint), {ImageTransparency = 0}):Play()
- TweenService:Create(TextLabel, TweenInfo.new(.25, Enum.EasingStyle.Quint), {TextTransparency = 0}):Play()
- end
- if Humanoid.Health > Humanoid.MaxHealth then
- TweenService:Create(Heart, TweenInfo.new(.15+.35*Humanoid.Health/Humanoid.MaxHealth, Enum.EasingStyle.Quint), {ImageColor3 = Color3.fromRGB(255,0,0)}):Play()
- Green:TweenSize(UDim2.new(1, 0, 1, 0), "Out", "Quad", .15+.35*Humanoid.Health/Humanoid.MaxHealth)
- TweenService:Create(Green, TweenInfo.new(.15+.35*Humanoid.Health/Humanoid.MaxHealth, Enum.EasingStyle.Quint), {BackgroundColor3 = Color3.fromRGB(0,255,0)}):Play()
- Trail()
- TextLabel.Text = math.floor(Humanoid.Health).." / "..math.floor(Humanoid.MaxHealth)
- elseif Humanoid.Health <= 0 then
- TweenService:Create(Heart, TweenInfo.new(.15+.35*Humanoid.Health/Humanoid.MaxHealth, Enum.EasingStyle.Quint), {ImageColor3 = Color3.fromRGB(0,0,0)}):Play()
- Green:TweenSize(UDim2.new(0, 0, 1, 0), "Out", "Quad", .15+.35*Humanoid.Health/Humanoid.MaxHealth)
- Trail()
- TweenService:Create(Green, TweenInfo.new(.15+.35*Humanoid.Health/Humanoid.MaxHealth, Enum.EasingStyle.Quint), {BackgroundColor3 = Color3.fromRGB(0,170,0)}):Play()
- TextLabel.Text = "0 / "..math.floor(Humanoid.MaxHealth)
- else
- TweenService:Create(Heart, TweenInfo.new(.15+.35*Humanoid.Health/Humanoid.MaxHealth, Enum.EasingStyle.Quint), {ImageColor3 = Color3.fromRGB(255*(Humanoid.Health/Humanoid.MaxHealth),0,0)}):Play()
- Green:TweenSize(UDim2.new(Humanoid.Health/Humanoid.MaxHealth, 0, 1, 0), "Out", "Quad", .15+.35*Humanoid.Health/Humanoid.MaxHealth)
- TweenService:Create(Green, TweenInfo.new(.15+.35*Humanoid.Health/Humanoid.MaxHealth, Enum.EasingStyle.Quint), {BackgroundColor3 = Color3.fromRGB(170/(Humanoid.Health/Humanoid.MaxHealth),255*(Humanoid.Health/Humanoid.MaxHealth),0)}):Play()
- Trail()
- TextLabel.Text = math.floor(Humanoid.Health).." / "..math.floor(Humanoid.MaxHealth)
- end
- PreviousHealth=Humanoid.Health
- end)
- while true do
- if Count <= 0 then
- TweenService:Create(Background, TweenInfo.new(.25, Enum.EasingStyle.Quint), {BackgroundTransparency = 1}):Play()
- TweenService:Create(Green, TweenInfo.new(.25, Enum.EasingStyle.Quint), {BackgroundTransparency = 1}):Play()
- TweenService:Create(Trail, TweenInfo.new(.25, Enum.EasingStyle.Quint), {BackgroundTransparency = 1}):Play()
- TweenService:Create(Heart, TweenInfo.new(.25, Enum.EasingStyle.Quint), {ImageTransparency = 1}):Play()
- TweenService:Create(TextLabel, TweenInfo.new(.25, Enum.EasingStyle.Quint), {TextTransparency = 1}):Play()
- end
- Count = Count-1
- wait(1)
- end
- function Trail()
- wait(1)
- print("Changed")
- --Trail:TweenSize(UDim2.new(1, 0, 1, 0), "Out", "Quad", .15+.35*Humanoid.Health/Humanoid.MaxHealth)
- --TweenService:Create(Trail, TweenInfo.new(.15+.35*Humanoid.Health/Humanoid.MaxHealth, Enum.EasingStyle.Quint), {BackgroundColor3 = Color3.fromRGB(0,255,0)}):Play()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement