Haven’t created a module in a while (a year to be exact, grinded a solid 18 minutes to make this one). You’re probably wondering… a GetPlayer library? Just keep reading it’ll make sense.
I’m talking :GetPlayerFromAbbreviation() type of functions. Don’t get bored now, keep reading.
I’ve created some pretty useful methods and functions you can use, only 3 in this module so far but I plan on adding more in the near future. Read the documentation and examples below.
Example
For reference, let’s say our test dummy’s name is “Programmer”.
module:GetPlayerFromAbbreviation("pro")
--> Returns 'Programmer' (Instance)
--> Nah, we don't do the case sensitive stuff here.
Documentation
module:GetPlayerFromAbbreviation(abbreviation,includeDisplayNames)
-- "abbreviation" parameter
-- Input the abbreviation of the player's name. For example, instead of bobby123, just input "bob".
-- Not case sensitive, "Bob" will work aswell.
-- "includeDisplayNames" parameter (optional)
-- Input includeDisplayNames as true or false. If true, the script will also search for displaynames with "bob" in it.
--RETURNS: Player (Instance) or false
--(Wondering the difference? You can get multiple players with this next function)
module:GetPlayersFromAbbreviation(abbreviation,includeDisplayNames)
-- "abbreviation" parameter
-- Input the abbreviation of player names, like "bobby" or "bo"
- Not case sensitive, "Bob" will work aswell.
-- "includeDisplayNames" parameter (optional)
-- Input includeDisplayNames as true or false. If true, the script will also search for displaynames with "bob" in it.
-- RETURNS: Players (Array) or false
module:GetPlayersInZone(ZonePart)
-- "ZonePart" parameter
-- Input the Zone (Instance) of the part you want to check if the player is in.
-- RETURNS: Player (Instance) or false
I think you’re mistaking the point of the creation of the module.
For example, if you want to make a custom admin script and you’d not want to have to type out the full usernames each time, try this:
local args = msg:split(" ")
if args[1]:lower() == ":kick" then
if args[2] then
local target = module:GetPlayerFromAbbreviation(args[2])
if target then
--> Do yo magic
end
end
end
local function ReturnPlayer(Str)
for i,v in next, Players:GetPlayers() do
if string.sub(v.Name:lower(),1,string.len(Str)) == Str:lower() then
return v
end
end
end
local function ReturnPlayers(Str)
local tab = {}
for i,v in next, Players:GetPlayers() do
if string.sub(v.Name:lower(),1,string.len(Str)) == Str:lower() then
table.insert(tab, v)
end
end
return tab
end
I fail to understand why you continue to say the function is useless when you can take the two seconds to scroll up and see that others found it useful. Of course anyone can integrate into their system, but you can’t even use that argument because all modules can be integrated a different way into someone’s system without actual use of the module. I asked for constructive critcism, not criticism only.