hi guys!
i'm trying to do something, but i am not sure how to do it. so basically, i have this string:
Username:true:Another Thing
I want to split it into 3 different strings: - Username - True (and make it a bool) - Another Thing
does anyone know how to do this?
You can use the function string.gmatch to solve your issue, I suggest for you to take a look at the String library and String Pattern as those will definitely help you with some string issues, at this case you could use this code for example to separate each string when there's an " : " on it.
local TheString = "Username:true:Another Thing" -- Your string for i in string.gmatch(TheString, "[^:]+") do -- Separates the string when it reaches " : " print(i) end
In this case it would make 3 different strings and out would output:
"Username" "true" "Another Thing"
Hopefully this helps you with your issue! Don't forget to accept it if it did solve it.