Putting "." multiple times in string

In my game, I want a loading screen that will repeat “Loading Game” and add a period “.” every .4 seconds. I’ve looked on the API but I can’t seem to find a way to multiply this period. I feel like if I use if statements in such a way like switch:case in other coding languages, the script will run too inefficiently.

Tl;DR - I want to “multiply” a string: e.g. “.” * 3 = “…”

1 Like

Just a little fun fact, this won’t work in Lua, but Python actually lets you multiply strings by a number. This is how you repeat strings, i.e. "hey" * 3 == "heyheyhey".


To repeat strings in Lua, use string.rep. So your code might look like this.

for i = 1, 3 do
    label.Text = "Loading" .. string.rep(".", i)
    wait(n)
end
12 Likes

alternatively (“.”):rep(x) and also this to do it based on time
("."):rep(math.floor(timeElapsed * speed) % amount)
where timeElapsed is usually tick() - start where start is the starting tick
speed is a multiplier for how fast
and amount makes it count from 0 to amount - 1 before resetting.
I usually use this instead for my loading screens since i update the majority of the gui constantly (usually every frame) to move things around and manipulate progress bars.
Should keep in sync with time too

3 Likes

Thanks, this definitely seems more optimized. I’ll use this in my loading screen.