I basically want to replicate the behavior we would see in C where strings are basically arrays. So suppose I had “Tree” that would become
{'T', 'r', 'e', 'e'}
I basically want to replicate the behavior we would see in C where strings are basically arrays. So suppose I had “Tree” that would become
{'T', 'r', 'e', 'e'}
local splitString: table = string.split("Hello", "")
Will return a table with all the characters separated in table values.
What is with the syntax after declaring the variable “splitString”? Can you elaborate?
It’s a Luau (Roblox syntax) type-hint for the variable definition.
So in roblox lua we would do
local splitString = string.split(string, "")
``` ??
No, you would write it exactly how I just wrote it.
But my paradigm isn’t luau, isn’t there a way I can do it in the non typed language?
I think the syntax you’re asking for is this, which works:
local splitString = str:split( "" )
This syntax is no longer working as I tried you can just do
local table = string.split(msg," ")
Don’t confuse “string
”, the library with “str
”, a string variable in my example.
So in your example, my example form of syntax would be:
msg:split( "" )
(Notice the colon, not period.)