Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can I get a player's full name while providing only half first name or just first one letter?

I am making my private give cash GUI which gives cash to player. It is so I or the player can get enough cash to test the items I am adding.

I always have to type the full name of the target player. I know it is possible to make a script which only requires you to type only first part of the name of the target player.

How can I do this? Please tell me. Like in admin commands you don't have to type the full name.

How can I do that? Please tell me, with an example(if you can give) as I understand much more by looking at an example.

Thanks!

1 answer

✓ Accepted answer

To accomplish this, we have to utilize :sub(). We simply split the name of the player into the length of the text we already have, and we check if the remaining text is equal.

local message --lets say this equals a chat message, in the case of admin commands

for _,v in pairs(game:GetService("Players"):GetPlayers()) do
  if v.Name:lower():sub(1,message:len()) == message:lower() then --lower and split as needed
    print("Found Target(s)")
  end
end

2 comments

0

Thank you!!!

0

You gotta mention what :sub means though.

This discussion is preserved as it was. New answers, comments, and votes are closed.