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

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

Asked by
Retroc 35
9 years ago

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

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. TheDeadlyPanther 2460 — 9y

2 answers

Log in to vote
0
Answered by 9 years ago
local number = leaderstats.Money

number.Value = Convert(number.Value) -- calls the function with required parameters (the number you are converting)
0
I put this code in the script but it has no effect. Retroc 35 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

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.

0
At line 20, leaderstats is underlined in a blue, and nothing is happening on the leaderboard. How do I define leaderstats better? Retroc 35 — 9y
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? Retroc 35 — 9y

Answer this question