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

How would i be able to print a random key given inside a Dictionary ? [solved]

Asked by
oSyM8V3N 429 Moderation Voter
6 years ago
Edited 6 years ago
local keyDictionary = {
    ["Q"] = false ,
    ["E"] = false ,
    ["R"] = false ,
    ["F"] = false ,
    ["D"] = false ,
    ["S"] = false ,
    ["H"] = false ,
    ["N"] = false ,
    ["Y"] = false ,
    ["U"] = false ,
    ["L"] = false
}

I tried using print(math.random(keyDictionary)), but it just gave me another error i don't even know about. If anyone can help, please do because I've been stuck on this for quite a long while :)

What i'm trying to do :

I have a script that when you press the T key, you enter a Training Mode, and so i want it to pick a random key from the keyDictionary and print it, or put the selected random Key into a variable called pressThis

0
Are you trying to return the key (ex: "Q") or the value (ex: true/false)? Also, why not just use a table? UnleashedGamers 257 — 6y
0
*print UnleashedGamers 257 — 6y
0
Im trying to make it pick a random key like (ex: "Q") as you said and change it to true when chosen oSyM8V3N 429 — 6y
0
And im not really used to using tables, someone told me to use a keyDictionary oSyM8V3N 429 — 6y

Answer this question