PlayersEssentials! - Handy player Utilities (Available)

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 :sob: (It is now available)

The idea is cool, but the only thing I didn’t understand, is why you created a find player by userID, if Players object already have this?

3 Likes

I actually meant to remove that because like you said I wasn’t really sure it fit in.

(This and I couldn’t really think of anything to add, and in all honesty didn’t know you could do this! Thank you!)

1 Like

If you’re struggling to think of things to add, then maybe it’s not the right time to create a utility library. Personally, I think utility functions should come from real, repeated needs—things you find yourself doing over and over in your scripts. While some of what you’ve included could be useful, like the player-related functions, a solid utility library usually grows naturally from your workflow.

In my experience, the best utilities are the ones you personally rely on—built out of what you actually need, not just what you think might be useful.

3 Likes

I think I know something you can add! A get character height function, that checks if character is R6 or R15, and then return the height of it!

1 Like

we already have GetPlayerByUserId()

you can just get leaderstats folder and get wins value or even use _G

most roblox experiences have anticheat so they use their own teleport method so players dont get falsely flagged

1 Like

Thank you for your feedback!!

Maybe in some time I will create a library that I find useful, and perhaps others can find very helpful. :grinning:

I can try! (Ineed30characterstopostwhattheheck!)

Okay, I’ll remove GetPlayerByUserId, but probably keep the LeaderStat Value and TeleportPlayer for players who either are newer to scripting, or don’t have an AntiCheat.

Thank you for your feedback!

I can give you the basic idea: After you check, get leg heigh, torso height, and head height, then return the sum of it! (I know, the30characters are annoying sometimes)

1 Like

instead of looping through each player you can just use instance lookup like this

	if Players:FindFirstChild(name) then 
		local PlayerFound = Players:FindFirstChild(name) 
		return PlayerFound
	end
	return nil 

or

	local PlayerFound = Players:FindFirstChild(name) 
        return PlayerFound

GetPlayerLeaderstatsValue wont work on values that are in folder it on ly checks for instances inside leaderstats folder

1 Like

I’ve actually got a basic version down: (Not sure if its the best way to do it)

function PlayersEssentials.GetCharacterHeight(character: Model): number
	if typeof(character) ~= "Instance" or not character:IsA("Model") then return nil end

	local humanoid = character:FindFirstChildOfClass("Humanoid")
	if not humanoid then return nil end

	local function getPartHeight(partName: string): number
		local part = character:FindFirstChild(partName)
		return part and part.Size.Y or 0
	end

	if humanoid.RigType == Enum.HumanoidRigType.R15 then
		return getPartHeight("Head")
			+ getPartHeight("UpperTorso")
			+ getPartHeight("LowerTorso")
			+ getPartHeight("LeftUpperLeg")
			+ getPartHeight("LeftLowerLeg")
			+ getPartHeight("LeftFoot")
	elseif humanoid.RigType == Enum.HumanoidRigType.R6 then
		return getPartHeight("Head")
			+ getPartHeight("Torso")
			+ getPartHeight("Left Leg")
	else
		return nil
	end
end
1 Like

Ah, I was quite tired yesterday as I wrote the module at two in the morning, so I made a few mistakes, lol. I’ll fix that.

1 Like

or local _, size = player.Character:GetBoundingBox() which also works with accessories

1 Like

Alright, re-wrote it to use GetBoundingBox()! Thank you for the feedback!

Okay, I see why GetPlayerByName is completely pointless now, it’s unbelievably easy to do. I’ll remove it.

1 Like

Yeah, because its easier to do Players:FindFirstChild(playerName)

1 Like

this is actual more useful resource than some other ones related to Players
(ezPlayers | A developer-friendly library for extending Roblox's Players service)

2 Likes