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

Is there a reason why my hearts are not changing?

Asked by
Joshument 110
5 years ago
Edited 5 years ago
local Player = game.Players.LocalPlayer
local Character = Player.Character
local Humanoid = Character:WaitForChild("Humanoid")
local Store = game.ReplicatedStorage

local HeartContainers = Character.HealthSetter.HeartContainers
local Health = Humanoid.Health

local renderstep = game:GetService("RunService").RenderStepped

renderstep:Connect(function()

    local Loaded = 1
    for i = 1, HeartContainers.Value do
        if Loaded < 11 then
            local Heart = Player.PlayerGui.HealthBar[tostring(Loaded)]
            if Heart.ImageTransparency == 1 then
                Heart.ImageTransparency = 0
            end
            Loaded = Loaded + 1
        end
    end

    local Number = 0
    local tn = 1
    local Table = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}

    while true do
        Number = Number + 2
        if Number < Health then
            Table[tn] = 2
            tn = tn + 1
        elseif Number == Health then
            Table[tn] = 2
            break
        elseif Number > Health then
            Table[tn] = 1
            break
        end
    end

    local Number1 = 0

    for i = 1, #Table do
        Number1 = Number1 + 1
        if Number1 < 11 and not 11 then
            local Heart = Player.PlayerGui.HealthBar[tostring(Loaded)]
            if Table[Number1] == 2 then
                Heart.Image = Store.HeartAssets.FullHeart.Image
            elseif Table[Number1] == 1 then
                Heart.Image = Store.HeartAssets.HalfHeart.Image
            elseif Table[Number1] == 0 then
                Heart.Image = Store.HeartAssets.NoHeart.Image
            end
        end
    end

end)

For some reason the new hearts I have display as a full heart (as they should) but none of the hearts seem to update. I've tried to troubleshoot but end up breaking it and no heart decals appear at all. Sorry for the flood lol

0
line 46 User#24403 69 — 5y
0
what about it ? Joshument 110 — 5y

Answer this question