✓ Accepted answer
I'm not aware of a built-in function for this, but it's quite straight-forward when you try to code it. Here's my example script:
function GetHighestNumberedPart()
local HighestVar = 0
local PartsTable = {}
local Children_Workspace = workspace:GetChildren()
for _, child in pairs(Children_Workspace) do
if child:IsA("Part") and child.Name ~= "Baseplate" then
table.insert(PartsTable, #PartsTable +1, child)
end
end
if #PartsTable > 0 then
for _,v in pairs(PartsTable) do
if tonumber(v.Name) > HighestVar then
HighestVar = tonumber(v.Name)
end
end
return workspace:FindFirstChild(tostring(HighestVar))
end
end
local HighestPart = GetHighestNumberedPart()
print(HighestPart.Name)
As you can see, I've created a function which returns the part with the highest numbered name. This function uses tonumber and tostring to convert the string/number, and then returns the match in workspace for us to access.
Hope this helps!
API References:
String Article ROBLOX Developer
Table.insert And Other Stuff
2 comments
Thank You! It worked.
Np! Glad I could help