How do I extract an ID from mesh/texture URL

I want to extract an ID from mesh/texture URl like (rbxassetid://1234567890 to 1234567890) or
( to 1234567890)

The problem is that my smooth brain can figure out how to do it, and I’ve tried to find a solution but only found a solution of “extract a number out of a string” but not “extract a string out of a number”.

Here is a script for it. This script is made to find a mesh or texture id that matches the filtertable
and show where it is!

local fiteridtable = {115337883,4107760344,722755763,560079780,560077355}


function point(obj) -- point obj location using billboard gui
	if obj and obj:IsA("BasePart") then
		local pointer = script.Pointer:Clone()
		pointer.Parent = obj
		pointer.Enabled = true

function checkmatch(obj,id)
	for _,v in pairs(fiteridtable) do
		if v == string.split() then -- idk how to do this
             -- check match then print full name and point to obj using billboard gui

for _,v in ipairs(workspace:GetDescendants()) do
	if v then
		if v:IsA("MeshPart") or v:IsA("SpecialMesh") then
			checkmatch(v, v.MeshId)
		elseif v:IsA("Decal")   then
			checkmatch(v, v.Texture)

Any help would be appreciated! :slightly_smiling_face:

This could work.

local args = string.split(v.MeshId, "=")

print(args[2]) -- prints "1234567890" if the string includes a "=" before the assetId.

You can use the pattern %d+ with match. This will check for the first occurrence of a digit and continue until the subsequent character doesn’t match the pattern and then return that query. This will work regardless of if you use the asset slug or the rbxassetid ContentId.

local links = {"", "rbxassetid://12345"}

for _, link in ipairs(links) do
    print(string.match(link, "%d+"))
end -- Both will print 12345
1 Like
local links = {"", "rbxassetid://12345"}

for _, link in ipairs(links) do
	print(string.match(link, "%d+$"))

You can minimise on CPU time by anchoring the search pattern to the end of the subject string via the dollar sign character.