decay = decay * 0.9
Trying to make decay go down by 10% repeatedly without making tons of decimals after it goes down a few times.
Well, you'd need to use a loop. Since you have no other code, I recommend you use a while loop!
decay = 2 -- Make sure to Set the value first! while wait(1) do decay = decay - (decay * .10) end
This can take a helluva lot of string manipulation and math, which can cause a helluva lot of frustration. I got it though.
decay = 10 --Initial value. decayfactor = .1 --Rate of decay. placesafterdecimal = 3 --Places after decimal. while wait(1) do decay = decay - (decay*decayfactor) stringdecay = tostring(decay) if string.find(stringdecay, ".") then local decimal = string.find(stringdecay, ".") local afterdecimal = string.sub(stringdecay, decimal + 2, string.len(stringdecay)) if string.len(afterdecimal) > placesafterdecimal then afterdecimal = tostring(math.floor(tonumber(afterdecimal)/10^(string.len(afterdecimal)-placesafterdecimal))) end local beforedecimal = string.sub(stringdecay, 1, decimal) local completestring = beforedecimal.."."..afterdecimal local completenumber = tonumber(completestring) print(completenumber) end end