Different text every log in

A Datastore for this isn’t really ideal because it’s pulling a random value so, that would just make it more complicated.

1 Like

Thank you dude!!!

as the OP implied in the topic, they want different text every log in (I assumed each time a player logs in, not displaying text displayed before , hence different).

DataStores are then useless in this case (not taking text displayed earlier into consideration)

No problemo man, and if you want to get fancy with it you could even add tweening to it also!

As @xurmx mentioned, you can make a table and pick random phrases from it with a random number. However, I’d recommend using Random.new() instead of math.random() for better performance, but if you use a seed players won’t know a difference unless they look at the code:

local r = Random.new() 

local tbl = { 
	"Message 1, "; 
	"Message 2, "; 
	"Message 3, "; 
} 

local n = r:NextInteger(1,#tbl) 
label.Text = tbl[n] .. game.Players.LocalPlayer.Name .. "!" 

This is just an example and as you can see it’s closely related to the solution @xurmx gave, but it implements Random.new() instead of math.random which ROBLOX recommends as a better practice.

I don’t understand much of scripting lol, am just chillin with being trash :frowning: thank you anyways!

Well, not totally useless maybe the dev wants a specific message only said once for each player then I see where a datastore would come in handy!

1 Like

math.random() now uses a similar algorithm to Random, what do you mean?

2 Likes

Like he said, he’s a beginner at scripting so I think math.random is very simple to understand.

1 Like

From what I know, math.random() was the original method of pulling random numbers, but ROBLOX later introduced Random.new() which was supposed to be a more improved version since math.random() had some issues (especially without a seed). If they then went back and re-improved math.random() to work similarly, then I was unaware of this and it seems pointless for them to even introduce Random.new() as an alternative unless I’m misunderstanding something here.

Still, thanks for the info! I’ll probably still use Random.new() out of habit, but good to know all the math.random() scripts aren’t poor in performance as I thought.

I suppose, and there’s nothing wrong with your code, but I just believed Random.new() was more efficient (and I don’t see how it’s more complicated than math.random()), but if what @XxELECTROFUSIONxX says is true, then I was wrong and your method is just as good as mine. My apologies!

No your method is just as good man, keep it up :call_me_hand:

1 Like
2 Likes

I’m a bit confused. Is it okay for the same text once in a while? Do you want a large set randomized, or do you want a new one every single time? If you make a new one every single time, that would take ages and you would eventually run out.

He already got a solution my good sir!

does local (name) actuually does something or it’s just a name?

I mean like local PossibleTexts
is the “possibletexts” named as something else in the system or i can change it’s name to whatever i want?

That is a variable name it can be changed to whatever you want! It just cannot have a number in it and your good to go!

1 Like

Thanks!!!

No problem my guy, secure scripting :rofl: :call_me_hand: :call_me_hand:

1 Like