I'm trying to make a randomized splash text system, for context, it is basically a system where for example one time I join the game it says "hello world" and another time I join, it has a different message like "world hello"
pls help thank you
What you could do is make a table containing every single splash text using like so:
local splashText = {"Hello world", "World hello"}
Then, you can select a splash text using this small piece of code splashText[1]
where the [1] is the position of the string in the table.
To select a random position in the table, you can use math.random like so:
math.random(amount of splash texts)
Math.random
will choose any whole number between 1 and the amount of splash texts you have.
Math.random
isn't truly random, so to make the randomness more randomy, you can add math.randomseed(tick())
in the line before you use math.random
.
Finally, you put all of those together and it should choose a random splash text every time you play.