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

How to create a randomized splash text?

Asked by 4 years ago

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

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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.

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 ankurbohra 681 — 4y
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! 20002000sa 83 — 4y
Ad

Answer this question