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

My hp/mana/level/gold ect lost connection to the script?

Asked by
nicros 165
9 years ago

So this might be a pretty big request, but i was creating with a gui and during testing i noticed my hp/mana/gold/and character speed/level all were broken, as if they all had no script attached to them.

They are all under StarterGui.HUD.Base

im not sure if something happened in the script, cant see that it would i didnt touch anything around the time it broke but heres the script they should all be attached to.

its a pretty big one, and im not sure if something happened where it lost connection to Base

If there is nothing wrong there is there something else that could have happened to cause this? all of the guis are stuff under Baseand all have their correct name as before they were broken.

any and all help is appreciated :) thanks for looking

repeat Game.StarterGui:SetCoreGuiEnabled("Health", false) wait() until Game.StarterGui:GetCoreGuiEnabled("Health") == false

local Player = Game.Players.LocalPlayer

repeat wait() until Player.Character ~= nil
repeat wait() until Player.Character:FindFirstChild("Humanoid")
repeat wait() until Player.leaderstats
repeat wait() until Player.Stats

Player.leaderstats:WaitForChild("Lvl")
Player.leaderstats:WaitForChild("Gold")

local HUD = Game.Players.LocalPlayer.PlayerGui.HUD

HUD.Base:WaitForChild("HealthBar")
HUD.Base.HealthBar:WaitForChild("Fill")
HUD.Base.HealthBar:WaitForChild("CurrentHP")

HUD.Base:WaitForChild("ManaBar")
HUD.Base.ManaBar:WaitForChild("Fill")
HUD.Base.ManaBar:WaitForChild("CurrentMP")

HUD.Base:WaitForChild("GoldBox")
HUD.Base:WaitForChild("WalkSpeed")
HUD.Base:WaitForChild("CharacterPortrait")
HUD.Base.CharacterPortrait:WaitForChild("Level")
HUD.Base:WaitForChild("CharName")

--Display character name.
HUD.Base.CharName.Text = Game.Players.LocalPlayer.Name

while true do
    if Player.Character:FindFirstChild("Humanoid") ~= nil then
        if Game.Workspace.Game_PROPERTIES.DefenseMode.Value == 3 then
            if Player.Stats:FindFirstChild("Defense") ~= nil then
                Player.Character.Humanoid.MaxHealth = (Game.Workspace.Game_PROPERTIES.StartingHP.Value) + (Game.Workspace.Game_PROPERTIES.HPPerLevel.Value * Player.leaderstats.Lvl.Value) + (Game.Workspace.Game_PROPERTIES.HPPerConstitution.Value * Player.attributes.Constitution.Value) + Player.Stats.Defense.Value
            end
        else
            Player.Character.Humanoid.MaxHealth = (Game.Workspace.Game_PROPERTIES.StartingHP.Value) + (Game.Workspace.Game_PROPERTIES.HPPerLevel.Value * Player.leaderstats.Lvl.Value) + (Game.Workspace.Game_PROPERTIES.HPPerConstitution.Value * Player.attributes.Constitution.Value)
        end
    end
    Game.Players.LocalPlayer.Stats.MaxMana.Value = (Game.Workspace.Game_PROPERTIES.StartingMP.Value) + (Game.Workspace.Game_PROPERTIES.MPPerLevel.Value * Player.leaderstats.Lvl.Value) + (Game.Workspace.Game_PROPERTIES.MPPerIntelligence.Value * Player.attributes.Intelligence.Value)
    --Refresh speed and gold display.
    HUD.Base.WalkSpeed.Text = math.floor(Player.Character.Humanoid.WalkSpeed)
    HUD.Base.GoldBox.Text = Player.leaderstats.Gold.Value
    --Refresh character icon.
    HUD.Base.CharacterPortrait.Character.Image = "http://www.roblox.com/thumbs/avatar.ashx?x=352&y=352&format=png&username=" ..Game.Players.LocalPlayer.Name
    HUD.Base.CharacterPortrait.Level.Text = "Lvl " .. Player.leaderstats.Lvl.Value
    --Refresh health and mana bar.
    if Player.Character:FindFirstChild("Humanoid") ~= nil then
        HUD.Base.HealthBar.CurrentHP.Text = math.floor(Player.Character.Humanoid.Health) .. " / " .. Player.Character.Humanoid.MaxHealth
        HUD.Base.HealthBar.Fill.Size = UDim2.new(0, (Player.Character.Humanoid.Health / Player.Character.Humanoid.MaxHealth) * 78, 0, 85) 
        if Player.Character.Humanoid.Health < (Player.Character.Humanoid.MaxHealth / 4) and Player.Character.Humanoid.Health ~= 0 then
            HUD.Critical.Visible = true
        else
            HUD.Critical.Visible = false
        end
        if Player.Character.Humanoid.Health == 0 then
            HUD.Dead.Visible = true
        else
            HUD.Dead.Visible = false
        end
    end
    HUD.Base.ManaBar.CurrentMP.Text = Player.Stats.Mana.Value .. " / " .. Player.Stats.MaxMana.Value
    HUD.Base.ManaBar.Fill.Size = UDim2.new(0, (Player.Stats.Mana.Value / Player.Stats.MaxMana.Value) * 78, 0, 85) 
    wait(0.1)
end

Answer this question