[SOLVED] Cannot set StringValue to a string chosen from an array?
Asked by
5 years ago Edited 5 years ago
Hello!
So I'm making a game with a character I would like to have a random name. I created two arrays or lists (whatever you choose to call them), each of them filled with names for the chosen gender (a random number between 0 and 1). Then, I checked the gender, and set the StringValue, "Name"'s value to the chosen name. I got the error:
Workspace.TourGuideData:21: attempt to index field 'Name' (a string value)
It sounds complicated, but it really isn't.
So here's my script:
05 | print ( "TourGuideData - Initialized" ) |
07 | berryColor = script.BerryColor |
09 | skinTone = script.SkinTone |
13 | berryColor.Value = BrickColor.Random() |
14 | skinTones = { "Pine cone" , "Dirt brown" , "Fawn brown" , "Cashmere" , "Khaki" , "Buttermilk" , "Institutional white" , "Burnt sienna" , "Teal" } |
15 | skinTone.Value = BrickColor.new(skinTones [ math.random( 1 , #skinTones) ] ) |
16 | gender = math.random( 0 , 1 ) |
19 | names = { "Mary" , "Sarah" , "Emma" , "Jamie" , "Eva" , "Jen" , "Alexandra" , "Patricia" } |
20 | script.Name.Value = names [ math.random( 1 ,#names) ] |
22 | names = { "John" , "Matthew" , "Patrick" , "James" , "Max" } |
23 | script.Name.Value = names [ math.random( 1 ,#names) ] |
Can someone help me figure out why I am getting this error and what I can do to fix it? Thanks!
-ProqrammedGreen