How do I make a script that detects shortened names of players in a TextBox?

My title was kinda confusing, but I’ll explain.

  1. What do you want to achieve? I want to have a TextBox that detects players even with shortened versions of the name.
    For example:
    In textbox: “shed”
    Script detects player with name “Shedletsky” because shed is found in Shedletsky’s name

  2. What is the issue? I’m not really sure how to do it. I know it’s something with strings, getting the Players, but I’m not sure how to really “execute” it.

  3. What solutions have you tried so far? I looked on the DevHub, and the DevForums, but I couldn’t find anything.

It’s kinda like in those cafe games and admin scripts, where you type “give 6c” or “ban mere”

Also, if you have a better way to name the title, please tell me

1 Like

Not sure exactly what you are trying to do here but I think this will help!

local name = "Barothoth"
local input = "bar"

print(input == string.lower(string.sub(name,0,string.len(input))))
--This prints true!

Here’s what’s happening:
string.len(input) = 3
string.sub(name,0,3) = “Bar”
string.lower(“Bar”) = “bar”
“bar” == “bar”

3 Likes

Thanks, I’ll try working with your script and see if it works with my needs.

1 Like