Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
local Humanoid = script:WaitForChild("Humanoid").Value; local HealthBar = script.Parent:WaitForChild("HealthBar"); local Main = HealthBar:WaitForChild("Main"); local HealthText = HealthBar:WaitForChild("HealthText"); local NameText = script.Parent:WaitForChild("NameText"); local healthBarColors = { Color3.fromRGB(0,200,0); Color3.fromRGB(200,200,0); Color3.fromRGB(200,200/3*2,0); Color3.fromRGB(200,0,0); Color3.fromRGB(200/3,0,0); }; local function rangePercentage(input,min,max) return ((input-min)*100)/(max-min); end; Main.BackgroundColor3 = healthBarColors[1]; local function updateBar(health,maxHealth) NameText.Text = Humanoid.DisplayName ~= "" and Humanoid.DisplayName or Humanoid.Parent.Name; NameText.Text = string.upper(NameText.Text); HealthText.Text = string.format("%02i / %02i",health,maxHealth); Main.Size = UDim2.new(health/maxHealth,0,1,0); if health/maxHealth <= 0.2 then local alpha = 1 - rangePercentage(health,0,maxHealth*0.2)/100; Main.BackgroundColor3 = healthBarColors[4]:lerp(healthBarColors[5],alpha); elseif health/maxHealth <= 1/3 then local alpha = 1 - rangePercentage(health,maxHealth*0.2,maxHealth*(1/3))/100; Main.BackgroundColor3 = healthBarColors[3]:lerp(healthBarColors[4],alpha); elseif health/maxHealth <= 0.5 then local alpha = 1 - rangePercentage(health,maxHealth*(1/3),maxHealth*0.5)/100; Main.BackgroundColor3 = healthBarColors[2]:lerp(healthBarColors[3],alpha); else local alpha = 1 - rangePercentage(health,maxHealth*0.5,maxHealth)/100; Main.BackgroundColor3 = healthBarColors[1]:lerp(healthBarColors[2],alpha); end; end; updateBar(Humanoid.Health,Humanoid.MaxHealth); Humanoid.HealthChanged:Connect(function(health) updateBar(health,Humanoid.MaxHealth); end);
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)