I have a StringValue with 3 words in it, separated by commas like so
Apple, Log, Cow
How would I in a script separate these values and use them without having to create 3 StringValues?
I have a StringValue with 3 words in it, separated by commas like so
Apple, Log, Cow
How would I in a script separate these values and use them without having to create 3 StringValues?
You can use string.split() for that, like so:
local Strings = "Apple, Log, Cow"
local SplitStrings = string.split(Strings, ", ")
SplitStrings will now be an array that has the strings: “Apple”, “Log”, “Cow” (Without commas)
Thank you so much!
How would I assign those values and then use them?
So say my StringValue in part has Apple, Log, Cow
I’d like the script to assign the first word “Apple” to “Fruit” the second word “Log” to “Item” and the third word “Cow” to “Animal”
so if I type print(“”…Animal) or whatever it would print the word Cow
You mean assign those words to variables? You can just do this:
local Fruit = SplitStrings[1] -- Apple
local Item = SplitStrings[2] -- Log
local Animal = SplitStrings[3] -- Cow
Since SplitStrings is an array you can access It’s values.