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
local number = leaderstats.Money number.Value = Convert(number.Value) -- calls the function with required parameters (the number you are converting)
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.