Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why does this abreviate not work ? Error down below.

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

2 comments

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

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.

1 answer

✓ Accepted answer

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

1 comment

0

Thank you a lot.

This discussion is preserved as it was. New answers, comments, and votes are closed.