Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Health Bar Script --
- local human = script.Parent.Parent.Parent.Parent:FindFirstChild("Humanoid")
- -- Change this to false if you want the health bar to be visible even when the player's health is full.
- -- If you leave it true, the health bar will disappear when the health is full.
- local hideBarAtFull = true
- human.HealthChanged:Connect(function(newHealth)
- local maxhp = human.MaxHealth
- if maxhp then
- if newHealth == maxhp then
- if hideBarAtFull then script.Parent.Visible = false end
- script.Parent.Frame.Size = UDim2.new(1,0,1,0)
- elseif newHealth < maxhp and newHealth > 0 then
- script.Parent.Frame:TweenSize(UDim2.new(newHealth/maxhp,0,1,0), "Out", "Quad", .25)
- script.Parent.Visible = true
- else
- script.Parent.Frame.Size = UDim2.new(0,0,1,0)
- script.Parent.Visible = true
- end
- end
- end)
- -- Script in StarterCharacterScripts --
- -- Change this line to true if you want the player to be able to see their own health bar.
- local showOverLocalPlayer = false
- -- Changes the seed.
- math.randomseed(tick())
- local colors = script.Colors:GetChildren()
- local color = colors[math.random(1,#colors)]
- local char = script.Parent
- local player = game:GetService("Players"):GetPlayerFromCharacter(char)
- local gui = script.Display
- -- Moves the GUI to the player's head, makes it so the player can't see it,
- -- and sets it up.
- gui.Parent = char.Head
- if not showOverLocalPlayer then gui.PlayerToHideFrom = player end
- gui.Frame.Script.Disabled = false
- gui.PlayerName.Text = script.Parent.Name
- gui.PlayerName.TextColor3 = color.Value
- -- Hide old player name.
- char.Humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
- script:Remove()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement