Categories > Coding > Lua >

How to make a GetPlayerWithInitials Function

Posts: 41

Threads: 17

Joined: Apr, 2018

Reputation: 0

Posted

(Limited Lua)
You know how in admin scripts, you don't need to do the full name of the player?
Like you type: ":kill rad" and it kills "radicalGuy52".

In order to do that, it just requires string manipulation with Limited Lua.

Heres an example:

You want to print to the output: a player's name. But you don't want to use the whole name.

In order to do that, we would do:
local target = "PlayerName"

for _, v in pairs(game:GetService('Players'):GetPlayers()) do
 Â Ã‚  if v.Name:lower():find(target:lower()) then
 Â Ã‚   Â Ã‚  print(v.Name);
 Â Ã‚  end
end
Change PlayerName to any part of the player's name (recommended: first four parts of it or so)
And it will print the player's exact name.

The base for this would be:


local target = "PlayerName"

for _, v in pairs(game:GetService('Players'):GetPlayers()) do
 Â Ã‚  if v.Name:lower():find(target:lower()) then
 Â Ã‚   Â Ã‚  -- Initialize your script here. 'v' is the Player object.
 Â Ã‚  end
end
  • 0

Posts: 14

Threads: 2

Joined: Apr, 2018

Reputation: 1

Replied

Nice contribution ðŸ‘
  • 0

Posts: 1

Threads: 0

Joined: May, 2018

Reputation: 0

Replied

INFINITE JUMP
  • 0

Users viewing this thread:

( Members: 0, Guests: 1, Total: 1 )