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

Why does this abreviate not work ? Error down below.

Asked by 3 years ago

So i made an abbreviation for a rebirth menu, is inside a local script in startergui parent to the textlabel.

local abbreviations = {
    N = 10^30;
    O = 10^27;
    Sp = 10^24;
    Sx = 10^21;
    Qn = 10^18;
    Qd = 10^15;
    T = 10^12;
    B = 10^9;
    M = 10^6;
    K = 10^3
}
local plr = game.Players.LocalPlayer

function abbreviateNums(number)


    local abbreviatedNum = number
    local abbreviationChosen = 0


    for abbreviation, num in pairs(abbreviations) do

        if number >= num and num > abbreviationChosen then

            local shortNum = number / num
            local intNum = math.floor(shortNum)

            abbreviatedNum = tostring(intNum) .. abbreviation .. "+"
            abbreviationChosen = num
        end
    end

    return abbreviatedNum
end




while wait(0.2) do
    script.Parent.Parent.Text = 'You need '.. abbreviateNums(10000 + (1000 * plr.leaderstats.Rebirths.Value)..' Money to rebirth.')
end

ERROR:

Players.ArchangelKingLegacy.PlayerGui.RebirthGui.Frame.TextForTop.TextLabel.LocalScript:24: attempt to compare number <= string  -  Client - LocalScript:24
0
One of these values are not a number (even if it looks like it is a number). You probably messed up somewhere, but I think I know a simple solution for this: just replace number on line 24 with tonumber(number); num with tonumber(num), ect MrSuperKrut 167 — 3y
0
It worked, thank you so much, you should put an answer so i can mark it as correct and you get some rep, thank you again i hope u have a great day. Hate_ZEU 47 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

One of these values are not a number (even if it looks like it is a number). You probably messed up somewhere, but I think I know a simple solution for this: just replace number on line 24 with tonumber(number); num with tonumber(num), ect

0
Thank you a lot. Hate_ZEU 47 — 3y
Ad

Answer this question