Hello everybody, I have this script that controls pet attacks I ran a print statement at the chest HP is going down, but the textLabel is stuck at 10M
The script is inside the textLabel.
This script basically abbreviates numbers and shows the abbreviated text.
local HealthText = script.Parent
local Chest = script.Parent.Parent.Parent.Parent
local Health = Chest.Health
local number = Health.Value
local abbreviations = {
K = 4,
M = 7,
B = 10,
Qa = 13,
}
local text = tostring(math.floor(number))
local ChosenAbbreviation
for abbreviation, digits in pairs(abbreviations) do
if #text >= digits and #text < (digits + 3 ) then
ChosenAbbreviation = abbreviation
break
end
end
if ChosenAbbreviation then
local digits = abbreviations[ChosenAbbreviation]
local rounded = math.floor(number/ 10 ^ (digits- 2 )) * 10 ^ (digits - 2 )
text = "HP:" .. string.format("%.1f", rounded / 10 ^ (digits - 1 ))..ChosenAbbreviation
--text = "" .. string.format("%.1f", rounded / 10 ^ (digits - 1 ))..ChosenAbbreviation.." HP"
else
text = "HP:"..number
end
while true do
HealthText.Text = text
wait(.1)
end