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:
--------------------------------------- ------ Written by ProqrammedGreen ----- --------------------------------------- print("TourGuideData - Initialized") berryColor = script.BerryColor name = script.Name skinTone = script.SkinTone --< Randomize >-- berryColor.Value = BrickColor.Random() skinTones = {"Pine cone", "Dirt brown", "Fawn brown", "Cashmere", "Khaki", "Buttermilk", "Institutional white", "Burnt sienna", "Teal"} skinTone.Value = BrickColor.new(skinTones[math.random(1, #skinTones)]) gender = math.random(0,1) names = nil if gender == 1 then names = {"Mary","Sarah","Emma","Jamie","Eva","Jen","Alexandra", "Patricia"} script.Name.Value = names[math.random(1,#names)] else names = {"John", "Matthew", "Patrick", "James", "Max"} script.Name.Value = names[math.random(1,#names)] end
Can someone help me figure out why I am getting this error and what I can do to fix it? Thanks!
-ProqrammedGreen