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.
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
Since * 0.9 is the same as -10%, the decimal problem is still there. And how it repeats isnt relevant.
If you want it to be a whole number, you could use math.floor to round down! http://wiki.roblox.com/index.php?title=Math.floor#math.floor
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
This discussion is preserved as it was. New answers, comments, and votes are closed.
3 comments
0.9 is 90 percent. And shawny is correct, can't multiply a word by a number!
How come the question is ONLY for Shawnyg? You can't do that, Once there was a question that was only for BlueTaslem and he himself said that you can't ask certain people to answer your question ONLY.
cuz shawny is an intelligent man