#making a stats system and running into a wall.

1 messages · Page 1 of 1 (latest)

dark prairie
#

well ive got the stats down and i make the health go up 10% per stat point but my health bars arent updating the health.
Heres the script for the health bar:

local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")

local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")

local healthFrame = script.Parent
local healthBar = healthFrame:WaitForChild("HealthBar")
local healthText = healthFrame:WaitForChild("HealthText")


local function updateHealthBar()
    local current = humanoid.Health
    local max = humanoid.MaxHealth
    local percent = math.clamp(current / max, 0, 1)
    local function formathealth(amount)
        amount = math.round(amount)
            if amount >= 1e12 then
            return string.format("%.2f T", amount / 1e12)
        elseif amount >= 1e9 then
            return string.format("%.2f B", amount / 1e9)
        elseif amount >= 1e6 then
            return string.format("%.2f M", amount / 1e6)
        elseif amount >= 1e3 then
            return string.format("%.1f K", amount / 1e3)
        else
            return tostring(amount)
        end
    end

    local targetSize = UDim2.new(percent, 0, 1, 0)
    local sizeTween = TweenService:Create(healthBar, TweenInfo.new(0.3, Enum.EasingStyle.Quad), {Size = targetSize})
    sizeTween:Play()





    healthText.Text = "HP: " .. formathealth(current) .. " / " .. formathealth(max)
end

humanoid:GetPropertyChangedSignal("MaxHealth"):Connect(updateHealthBar)
humanoid:GetPropertyChangedSignal("Health"):Connect(updateHealthBar)
updateHealthBar()
paper hedgeBOT
#

studio** You are now Level 3! **studio

surreal mantle
#

You forgot to add that I think.

dark prairie
#

I dont think so since the function already calls the formatting. It just when i put stat points the ui doesnt update unless i reset char

surreal mantle
#

Your right.