Garry's Mod Wiki

string.rep

  string string.rep( string str, number repetitions, string separator = "" )

Description

Repeats a string by the provided number, with an optional separator.

Arguments

1 string str
The string to convert.
2 number repetitions
Times to repeat, this value gets rounded internally.
3 string separator = ""
String that will separate the repeated piece. Notice that it doesn't add this string to the start or the end of the result, only between the repeated parts.

Returns

1 string
Repeated string.

Example

Repeating "abc" 5 times.

print(string.rep("abc", 5))
Output: abcabcabcabcabc

Example

Repeating "hello world" 3 times, with the separator " " (space).

print(string.rep("hello world", 3, " "))
Output: hello world hello world hello world