Roblox Scripting Tutorial: Custom Overhead Health Bar

แชร์
ฝัง
  • เผยแพร่เมื่อ 1 ธ.ค. 2024

ความคิดเห็น • 13

  • @moggie
    @moggie 5 ปีที่แล้ว +2

    I love you! Thank you so much for this tutorial :D

  • @woopling
    @woopling 5 ปีที่แล้ว

    Thank you! Now I know how to make my Gui don't look garbage! :D

  • @juanbarriga2982
    @juanbarriga2982 3 ปีที่แล้ว

    Can I please have the project files to his tutorial.

  • @Zachcoppock
    @Zachcoppock 5 ปีที่แล้ว

    The name works but the health bar does not, Any help?
    Here's what i did to the script if it helps
    local human = script.Parent:FindFirstChild("Humanoid")
    local hideBarAtFull = false
    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)
    here's the other script
    -- Health Bar Script --
    local human = script.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 = false
    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 = true
    -- 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()

  • @itsafake3462
    @itsafake3462 5 ปีที่แล้ว

    Thank you so much!

  • @xxdevxx2406
    @xxdevxx2406 4 ปีที่แล้ว

    What do you put in the Custom Health script

  • @brolion1871
    @brolion1871 5 ปีที่แล้ว

    Great video!

  • @marlosuper
    @marlosuper 4 ปีที่แล้ว

    Hey, does this still work?

    • @marlosuper
      @marlosuper 4 ปีที่แล้ว

      @@Rrrrry123 thanks

  • @philhogg8969
    @philhogg8969 3 ปีที่แล้ว

    Amazing tutorial - just what I needed and worked perfectly. But I'm afraid you don't spell colour the proper way! :)

    • @be-gau_tv2941
      @be-gau_tv2941 3 ปีที่แล้ว

      I believe it's American English and British English that spells words differently? Correct me if I'm wrong.

    • @vidyuthegde648
      @vidyuthegde648 3 ปีที่แล้ว +1

      it's spelled correctly.

    • @philhogg8969
      @philhogg8969 3 ปีที่แล้ว

      @@be-gau_tv2941 I was being sarcastic. For this very reason.