Is there a better way?

local dialog = script.Parent

local sickness ="DialogChoice")

sickness.Name = "sickness"

sickness.Parent = script.Parent

sickness.UserDialog = "What do you have?"

local sicknesses = {

"I am sick",

"I am ill",

"I need to go",




sickness.ResponseDialog = sicknesses[math.random(1,#sicknesses)]

I made this code that picks a random speech but it always picks the same speech I have to restart the game for it to pick another speech. I fixed it by using a while true loop but is there a better way to fix this?

I don’t really know, but this:

Could just be dialog, as you defined that as script.Parent.

Yes, it is a dialog. (30 char limit)

I edited my response, should make more sense now

1 Like

There’s really no better way, its as good as it gets. You’d be doing needless optimization otherwise.

If you want to really be needlessly optimizing your code, localize the script’s parent as a variable.

1 Like