Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago
Edited 5 years ago

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

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

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
0
Thank you!!! StrategicPlayZ 58 — 5y
0
You gotta mention what `:sub` means though. Zafirua 1348 — 5y
Ad

Answer this question