Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- HPBar
- -- Version: 0.0.1
- -- By pawela827
- local HealthBar = Instance.new("ScreenGui")
- local HealthFrame = Instance.new("Frame")
- local Bar = Instance.new("Frame")
- local HealthText = Instance.new("TextLabel")
- HealthBar.Name = "Health Bar"
- HealthBar.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
- HealthFrame.Name = "HealthFrame"
- HealthFrame.Parent = HealthBar
- HealthFrame.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
- HealthFrame.BackgroundTransparency = 0.500
- HealthFrame.LayoutOrder = 1
- HealthFrame.Position = UDim2.new(0, 5, 0, 100)
- HealthFrame.Size = UDim2.new(0, 200, 0, 40)
- Bar.Name = "Bar"
- Bar.Parent = HealthFrame
- Bar.BackgroundColor3 = Color3.fromRGB(85, 255, 0)
- Bar.Size = UDim2.new(0, 200, 0, 40)
- HealthText.Name = "HealthText"
- HealthText.Parent = HealthFrame
- HealthText.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
- HealthText.BackgroundTransparency = 1.000
- HealthText.Size = UDim2.new(1, 0, 1, 0)
- HealthText.Font = Enum.Font.SourceSansBold
- HealthText.Text = "HP: 100/100"
- HealthText.TextColor3 = Color3.fromRGB(255, 255, 255)
- HealthText.TextSize = 24.000
- HealthText.TextWrapped = true
- local function _script()
- local script = Instance.new('Script', HealthBar)
- game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Health,false)
- local player = game.Players.LocalPlayer
- local char = player.Character
- local gui = script.Parent
- local frame = gui.HealthFrame
- local bar = frame.Bar
- local text = frame.HealthText
- while wait() do
- text.Text = "HP: "..math.floor(char:WaitForChild("Humanoid").Health).."/"..char:WaitForChild("Humanoid").MaxHealth
- bar.Size = UDim2.new(0,(char:WaitForChild("Humanoid").Health / char:WaitForChild("Humanoid").MaxHealth * 200),1,0)
- end
- end
- coroutine.wrap(_script)()
Advertisement
Add Comment
Please, Sign In to add comment