Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Making a Number go up to give a illusion?

Asked by 5 years ago
Edited 5 years ago

I have a question to ask if what im asking is possible. Im recreating cookie clicker. in it, it gives the illusion that you are earning tons of cookies instead of the cookies counter going up every second. is that possible to make that in roblox?

Example of what im trying to say. if you launch the cookie clicker game on the browser. and you get 2x click, which makes it so you can get 2 cookies when u click. it doesn't instantly update to 2, it quickly but slowly enough to go from 1, to 2, its a neat illusion and i want it to be in this one aswell. Of course when you're at like 100, its quickly enough that it can go up to 100 in a second.

0
Wait, doesn't it just update the number? Can you show what you are talking about. ForeverBrown 356 — 5y

1 answer

Log in to vote
1
Answered by
royaltoe 5144 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

use a for loop:

function updateNumber(finalNumber)
    local waitTime = 1/finalNumber -- figure out how long we have to wait per number to make sure the value gets changed to final number every second
    for i = 1, finalNumber do
        --TODO: change the numCookies text box to be the number 'i'
        wait(waitTime)
    end
end

updateNumber(100)


as Overscores said, the minimum wait() can be 1/30th of a second so any number smaller than that will be longer than a second.

0
Best explain ever. Upvoted. Xapelize 2658 — 5y
0
Usually, wait() only functions at 30 per second, so any number above 30 won't finish in one second. Overscores 381 — 5y
Ad

Answer this question