hello. I am messing with Textlabels.
lets imagine, i got a textlabel
then i got a number
i put that number on the gui and the text is “1”
how would i make it display “001” instead of “1” and “020” instead of “20”?
any help is appreciated!
hello. I am messing with Textlabels.
lets imagine, i got a textlabel
then i got a number
i put that number on the gui and the text is “1”
how would i make it display “001” instead of “1” and “020” instead of “20”?
any help is appreciated!
You could use this:
local number=20 -- lets think 20 is your number (example)
local function getDigits(no) -- to know how many digits are in the number
local NewNumber=tostring(no)
local letters=0
for i=1, string.len(NewNumber), 1 do
letters+=1
end
return letters
end
local digits=getDigits(number)
if digits==1 then
text="00"..number
elseif digits==2 then
text="0"..number
elseif digits==3 then
text=number
end
Or we could just use the following:
local sVal = string.format("%.3d", val) -- val contains 1 or 20 or whatever value you want to convert
would that fr work? how are you that smart?
thanks for trying to help but @quakage was more simple and space saving!
look inside my other topics, maybe you could solve them?
thanks however! (:
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.