What’s this?
PlayerEssentials is a simple module with useful functions to make handling players easier. Stuff like finding players by name or ID, getting players near a spot, sorting them by distance, teleporting, and grabbing leaderstats — all wrapped up so you don’t have to write it yourself every time.
Why use it?
Player-related code can get annoying and repetitive. This saves you the hassle by giving you a ready set of tools to speed up your work.
Features
Find players by full or partial name
Returns an array of players whose names match or partially match the given string (case-insensitive).
Usage:
PlayersEssentials.GetPlayersByName("someName")
Returns all players with “someName” in their username.
Find player by UserId
Returns the player object with the given UserId, or nil if not found.
Usage:
PlayersEssentials.GetPlayerByUserId(123456789)
Get players near a position
Returns an array of players whose HumanoidRootPart is within a specified radius from a Vector3 position.
Usage:
PlayersEssentials.GetPlayersWithinRadius(Vector3.new(0,10,0), 50)
Find closest player to a spot, ignoring whoever you want
Returns the player closest to a Vector3 position. Optionally exclude a player from the search.
Usage:
PlayersEssentials.GetClosestPlayerToPosition(Vector3.new(0,10,0), playerToIgnore)
Sort players by distance
Returns a table of players sorted by their distance from a given position.
Usage:
PlayersEssentials.SortPlayersByDistance(Vector3.new(0,10,0))
Get leaderstats values
Returns the value of a leaderstat for a given player. Returns nil if the stat or leaderstats folder doesn’t exist.
Usage:
PlayersEssentials.GetLeaderstatValue(player, "Wins")
Teleport players
Instantly teleports a player’s HumanoidRootPart to a specified Vector3 position.
Usage:
PlayersEssentials.TeleportPlayer(player, Vector3.new(100,10,100))
Find players with a specific tag
Returns an array of players who have a specific tag set via CollectionService.
Usage:
PlayersEssentials.GetPlayersWithTag("VIP")
How you can use it
local PlayersEssentials = require(game.ReplicatedStorage.Modules.PlayerEssentials)
game.Players.PlayerAdded:Connect(function(player)
wait(5)
local near = PlayersEssentials.GetPlayersWithinRadius(Vector3.new(0,10,0), 50)
print("Nearby players:", #near)
local closest = PlayersEssentials.GetClosestPlayerToPosition(Vector3.new(0,10,0), player)
print("Closest player:", closest and closest.Name)
PlayersEssentials.TeleportPlayer(player, Vector3.new(100,10,100))
end)
How to get it
Get the module here: https://create.roblox.com/store/asset/85831761819009/PlayersEssentials
Note:
This is my first time creating a library- well atleast one for public use, I wanted to create a library that allows you to manipulate the player or get specific info or even niche things that take a little bit of thinking to script.
Any feedback is welcomed and appreciated, should I make more?
Edit: I forgot to make it distributed (It is now available)