Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to create a randomized splash text?

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

1 answer

✓ Accepted answer

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.

2 comments

0

math.random will give you an integer: “ When called with two integer numbers m and n, math.random returns a uniform pseudo-random integer in the range [m, n].” from https://developer.roblox.com/en-us/api-reference/lua-docs/math

0

Thanks, I could've sworn I read somewhere that it also outputted decimals. Thanks for correcting me, I changed my answer to spit out straight facts!

This discussion is preserved as it was. New answers, comments, and votes are closed.