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 HealthText = script.Parent.Vida
- local Bar = script.Parent.Bar
- local Player = game.Players.LocalPlayer
- repeat wait() until Player.Character or Player.CharacterAdded:Wait()
- local Character = Player.Character
- local Humanoid = Character:FindFirstChild("Humanoid")
- local GreenColor = Color3.fromRGB(0, 170, 0)
- local RedColor = Color3.fromRGB(170, 0, 0)
- local YellowColor = Color3.fromRGB(154, 154, 0)
- Humanoid.HealthChanged:Connect(function(Health)
- local Health = math.floor(Health)
- Bar.Size = UDim2.new(0, Health*2, 0, 20)
- HealthText.Text = tostring(Health .. "%")
- if Health >= 75 then
- Bar.BackgroundColor3 = GreenColor
- elseif Health < 60 and Health > 40 then
- Bar.BackgroundColor3 = YellowColor
- elseif Health < 40 then
- Bar.BackgroundColor3 = RedColor
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement