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

How do I use / activate this script? [Not answered]

Hello. I have a script that converts my leaderstat of Cash from a big number and abbreviates it so it fits and looks nice. However, I am really inexperienced as a scripter and have no idea how to call this function or have it loop. I am also confused for what to put in the Heiracy. If someone could help by telling me where to put and how to run this script that'd be great.

function Convert(num)
local x = tostring(num)
if #x>=13 then
local num1 = (#x-12)
return x:sub(0,(num1)).."."..(x:sub(#x-10,(#x-10))).."Q+" --Quadrillion
elseif #x>=10 then
    local num1 = (#x-9)
    return x:sub(0,(num1)).."."..(x:sub(#x-7,(#x-7))).."B+" --Billion
elseif #x>= 7 then
 local num1 = (#x-6)
 return x:sub(0,(num1)).."."..(x:sub(#x-5,(#x-5))).."M+" --Million
elseif #x>=4 then
    return x:sub(0,(#x-3)).."."..(x:sub(#x-2,(#x-2))).."K+" --Thousand
else
return num
end
end
Convert()-- whatever your currencys Heiracy is

1 comment

0

When copying code from scriptinghelpers, in the top right corner of the code box, there should be a double page icon. Use that to copy code, so there is no '1', '2' etc. on every second line of your code.

2 answers

local number = leaderstats.Money

number.Value = Convert(number.Value) -- calls the function with required parameters (the number you are converting)

1 comment

0

I put this code in the script but it has no effect.

Adding what your script says, and what TheDeadlyPanther said.

function Convert(num)
local x = tostring(num)
if #x>=13 then
local num1 = (#x-12)
return x:sub(0,(num1)).."."..(x:sub(#x-10,(#x-10))).."Q+" --Quadrillion
elseif #x>=10 then
    local num1 = (#x-9)
    return x:sub(0,(num1)).."."..(x:sub(#x-7,(#x-7))).."B+" --Billion
elseif #x>= 7 then
 local num1 = (#x-6)
 return x:sub(0,(num1)).."."..(x:sub(#x-5,(#x-5))).."M+" --Million
elseif #x>=4 then
    return x:sub(0,(#x-3)).."."..(x:sub(#x-2,(#x-2))).."K+" --Thousand
else
return num
end
end
Convert()-- whatever your currencys Heiracy is

local number = leaderstats.Money

number.Changed:connect(function()
	number.Value = Convert(number.Value)
end)

I can't test it right now cause internet is really laggy, tell me if it doesn't work.

2 comments

0

At line 20, leaderstats is underlined in a blue, and nothing is happening on the leaderboard. How do I define leaderstats better?

0

Also, the leaderstat is 'Cash' but I fixed that and I'm still getting the blue underline. Should this be in a local script maybe?

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