How would I stop sub of a string before a space

I believe the title says it all. while doing string.sub u have to follow this pattern: string.sub(text, startindex, endindex)
I want to stop the sub (whatever u call it) before a space (or after, if before is not possible) and return back the index where the space is. thanks

It sounds like you want string.find.

local index = string.find(text, " ", startindex, true)

But I bet there’s a better way depending on what you need. If you’re doing commands as is so commonly asked, you can get a list of every word by using string.split

local arguments = string.split(text, " ")
if arguments[1] == "kick" then
    local player = game.Players:FindFirstChild(arguments[2])
2 Likes

Will test and reply back.
30-character

it worked. thanks for helping me hope u have a good day ahead

1 Like