Convert string to dictionary value

  1. What do you want to achieve?
    I have a dictionary of skin colors and I want to use the StringValue that I have to reference the dictionary.

  2. What is the issue?
    I can’t use a string value to reference the dictionary because it does not take in a string value.

  3. What solutions have you tried so far?
    I have tried changing the type but I am unsure how to do this. I also looked up how to change string type but didn’t find anything about dictionaries.

local Value = "Skin1"  

local SkinColors = {
    Skin1 = Color3.fromRGB(254, 243, 187),
    Skin2 = Color3.fromRGB(255, 190, 125),
    Skin3 = Color3.fromRGB(255, 170, 127), 
    Skin4 = Color3.fromRGB(221, 147, 110),
    Skin5 = Color3.fromRGB(173, 115, 86), 
    Skin6 = Color3.fromRGB(131, 87, 65), 
    Skin7 = Color3.fromRGB(255, 170, 0), 
    Skin8 = Color3.fromRGB(107, 71, 53),
    Skin9 = Color3.fromRGB(70, 46, 35), 
    Skin10 = Color3.fromRGB(49, 32, 24), 
    Skin11 = Color3.fromRGB(34, 22, 17), 
    Skin12 = Color3.fromRGB(170, 85, 0)
}


print(SkinColors.Value) -- SkinColors.Value does not work as strings don't work 
print(SkinColors[Value])
4 Likes