Im currently working on a retro inspired game and i was just wondering is it possible to recreate a scoring display that involves 6 digits and numbers that only count in the front, for example: i want it to start out: 000000, and when you score it goes up to 001000.
This is what im talking about here:
I tried to search the forums for a answer but i couldn’t find any, i need some help on how to do this.
yeah its definitely possible to recreate that display but it will require a knowledgeable understanding of string manipulation and formatting and basic math operations.
Actually never mind there is a much easier idea i thought about .
Try this code when updating the score textlabel:
local scoreBonus=1000 --any number
local currentScore= script.Parent.Text–Your score already
local score=math.clamp(currentscore,000000,999999) – your min and max value can be anything
script.Parent.Text=currentScore+score --Dont worry strings and numbers add together depending on the string is representation
I mean this is a very basic example but should work, why not just use conditionals to check the score amount and concatenate it with the textlabel? Like this:
inital_text = "000000"
if (value >= 0 and < 10) then --000001 -> --000009
inital_text = "SCORE".."00000"..value
elseif (value >= 10 and value < 100) then --000010 -> --000099
inital_text = "SCORE".."0000"..value
elseif (value >= 100 and value < 1000) then --000100 -> --000999
inital_text = "SCORE".."000"..value
elseif (value >= 1000 and value < 10000) then --001000 -> --009999
inital_text = "SCORE".."00"..value
elseif (value >= 10000 and value < 100000) then --010000 -> --099999
inital_text = "SCORE".."0"..value
else --100000 -> --999999
inital_text = "SCORE"..value
end
Im sure you can make this in a loop or something or some alternate way to suit your lazy typing fingers. But I’m not too sure if any math equation will work, since any number like “001” will just turn to “1”, or any number like “000” will turn to “0”.