Separating strings by spaces

So i’m trying to make a simple item quality system, that would have a different background color based on quality.
with how things are set up now, it’d be easiest to go off object name. (since this is only for client-side display, and doesn’t affect other players)

so i have like… ‘Common sword’ or ‘Legendary dagger’
how do i split the string to just be the first word?

EDIT: i haven’t really tried anything because i understand nothing about string manipulation .-.


You can call string.split on the string with the separator argument as a space to get each set of characters that are separated by strings. If you want to learn more about string manipulation I recommend reading this. Hope this helps :slight_smile:


local str = string.split("Hello World!", " ")

table.foreach(str, print)

	1	Hello
	2	World!

Thanks you!

geez, like a 10 minute search on the wiki probably could have brought up that function i needed…
i’ll be sure to read over the reference