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

[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:

01---------------------------------------
02------ Written by ProqrammedGreen -----
03---------------------------------------
04 
05print("TourGuideData - Initialized")
06 
07berryColor = script.BerryColor
08name = script.Name
09skinTone = script.SkinTone
10 
11--< Randomize >--
12 
13berryColor.Value = BrickColor.Random()
14skinTones = {"Pine cone", "Dirt brown", "Fawn brown", "Cashmere", "Khaki", "Buttermilk", "Institutional white", "Burnt sienna", "Teal"}
15skinTone.Value = BrickColor.new(skinTones[math.random(1, #skinTones)])
View all 24 lines...

Can someone help me figure out why I am getting this error and what I can do to fix it? Thanks!

-ProqrammedGreen

0
Fixed. I realized Name is also a property of a script, so I changed the name of the stringvalue to "namevalue proqrammed 285 — 5y
0
Fixed. I realized Name is also a property of a script, so I changed the name of the stringvalue to "namevalue" to not confuse the script proqrammed 285 — 5y
0
cheers royaltoe 5144 — 5y

Answer this question