I am using a dictionary because I am using the keys in the dictionary so that I know a certain dialogue option corresponds to a type of item. I want to have the VALUES (NOT THE KEYS) of the array/dictionary to be picked at random but I keep getting an error saying " 'random' (interval is empty) "
Here is my code
local initialPrompts = {
["osv"] = "Hello there, one scoop of vanilla please.",
["osv"] = "Let me have one scoop of vanilla ice cream.",
["osc"] = "I'd like one scoop of chocolate ice cream."
}
local choicePrompts = {"Thanks", "Thank You", "Have a nice day", "Enjoy your day"}
local dialog = script.Parent.Brain.Dialog
local iceCreamChoice = script.Parent.icecreamchoice
enabled = true
if enabled == true then
enabled = false
math.randomseed(tick())
local chosenInitialPrompt = initialPrompts[math.random(1,#initialPrompts)]
print(chosenInitialPrompt)
enabled = true
end

1 comment
'math.random(a, b)' will throw that error if there is no integer between the range 'a-b', where both 'a' and 'b' are inclusive. By the way, you can omit '1' if you want 'math.random' to give a random value between '1' and some other number.