Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I center the billboard GUI and locking it's size ?

Asked by 7 years ago
game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(char)
        local plyrGuiH = Instance.new("BillboardGui")
        plyrGuiH.Name = "HealthOverlay"
        plyrGuiH.Parent = char.Head
        plyrGuiH.Adornee = char.Head
        plyrGuiH.Size = UDim2.new (1,0,1,0,0,0)
        plyrGuiH.StudsOffset = Vector3.new (0,1.2,0)
        --plyrGuiH.PlayerToHideFrom = player

        local frame = Instance.new("Frame")
        frame.Parent = plyrGuiH
        frame.Size = UDim2.new (0,180,0,10)
        frame.BackgroundColor3 = Color3.fromRGB (9, 33, 49)

        local overlay = Instance.new("Frame")
        overlay.Parent = frame
        overlay.Name = "Overlay"
        overlay.BackgroundColor3 = Color3.fromRGB (255, 24, 58)
        overlay.Size = UDim2.new (0,180,0,10)

    game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Health, false)
    local Humanoid = player.Character:WaitForChild("Humanoid")
    local HealthMath = Humanoid.Health / (Humanoid.MaxHealth)
    wait()
    overlay:TweenSize(UDim2.new(HealthMath, 0, 1, 0), "Out", "Sine", .5)

    Humanoid.HealthChanged:connect(function()
        local HealthMath = Humanoid.Health / (Humanoid.MaxHealth)
        overlay:TweenSize(UDim2.new(HealthMath, 0, 1, 0), "Out", "Sine", .5)
    end)

    end)
end)

And how do I limit the distance of the GUI?

0
Do you mean limit the distance of visibility? Like for example if you zoom out all the way it doesn't show up like massive text in the way of everything? CommanderSkywalkerTR 5 — 7y
0
Yup xiFrosty 13 — 7y

Answer this question