HowToRoblox

CountEffect

Oct 25th, 2020 (edited)
727
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local txtLabel = script.Parent
  2.  
  3. local timeTo100 = 5
  4.  
  5.  
  6. local isRunning = false
  7. local function countNumEffect(startN, endN, inc, waitTime)
  8.    
  9.     isRunning = true
  10.    
  11.     for i = startN, endN, inc do
  12.  
  13.         if not isRunning then return end
  14.  
  15.         txtLabel.Text = i
  16.         wait(waitTime)
  17.     end
  18.    
  19.     txtLabel.Text = endN
  20.    
  21.     isRunning = false
  22. end
  23.  
  24.  
  25.  
  26. local startNum = tonumber(txtLabel.Text)
  27. local endNum = 0
  28.  
  29. local negator = 0
  30. local increment = 1
  31.  
  32. if endNum < startNum then negator = -1; increment = -1 end
  33.  
  34.  
  35. local waitTime = (negator + ((timeTo100 / 100) * math.abs(endNum - startNum))) / 100
  36.  
  37.  
  38. if waitTime < (1/30) then
  39.     local numsPerWait = math.ceil((1/30) / waitTime)
  40.     increment = increment * numsPerWait
  41. end
  42.  
  43.  
  44. isRunning = false
  45. countNumEffect(startNum, endNum, increment, waitTime)
RAW Paste Data