Would anyone know how to get the individual package body part IDs from the original package ID (e. g. left arm, right arm, torso, etc.)? I’m trying to write an admin script, and I can’t seem to figure out a way to make this work.
EDIT: Some people don’t seem to exactly understand what I’m trying to do here. I would like to get the mesh/body part IDs for the indiviual limbs so I can apply it to the character being used. I am using R6, not R15. I can’t just, you know, go on the website and copy-paste the ids, because i’m trying to make this run through a script.
EDIT 2: Here’s the code that I want to get the package limbs Id from.
local function packageCMD(plrs, info)
for i = 1, #plrs do
--code goes here
end
end
The plrs argument is a table that contains all players that are referenced in the command (example, “others”, or “all”). The info argument is the id of the package that I want to get the package parts from.
EDIT 3: After doing a bit of research, I have discovered that what I am trying to do is get the charactermesh id from the bodypart id, which i need to get from the package id. Just for more clarification.
I believe for r15 characters you can get the MeshId of the limbs (MeshPart.MeshId). You could go through each package and create a table of all the limbs and their asset ids.
Not sure if there’s a better way.
Edit: for some reason when I read your post I assumed you wanted to get the user’s current package. Anyways, the best way to get the MeshIds for all the packages is to go to the package then scroll down to included items, where it’ll show all of the limbs. You can then copy those ids.
Apoplogies, but this is not useful, as I am using R6 in my game, and I can’t just copy and paste individual links from the roblox website. I’m trying to write a script.
My bad, assumed you were using R15. I think you were confused about what I said with the links, as links contain asset ids (mesh ids). However, I realized that when you go to a limb from a package the mesh is actually a seperate asset, meaning the asset id contained in the url of the body part wont work.
I figured out that if you go to a limb from a package, then use BTRoblox to inspect the package, and scroll down to the R6 folder there will be a character mesh containing the mesh’s asset id as its meshid.
In R6, the meshes of the character’s bodyparts are controlled by CharacterMeshes parented to the character model. You can change the meshid of the CharacterMeshes to the asset id of a limb from a package to convert that limb into the limb used by the package.
Example code:
local packages = {
woman = {
RightLeg = 746825633,
LeftLeg = 746826007,
RightArm = 83001181,
Torso = 82987757,
Head = 8635368421,
LeftArm = 83001137,
}
}
local function convertToPakcage(character,packageTable)
-- remove all character meshes because it's easier to create new ones instead of changing these.
for _,v in pairs(character:GetChildren()) do
if v:IsA"CharacterMesh" == false then continue end
v:Destroy()
end
-- go through all of the body part types and create the meshes.
for _,v in pairs(Enum.BodyPart:GetEnumItems()) do
local cmesh = Instance.new("CharacterMesh",character)
cmesh.BodyPart = v
cmesh.MeshId = packageTable[v.Name]
end
end
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
convertToPakcage(char,packages.woman)
end)
end)
The ids for the parts were obtained using the method explained above.
Hope this wasn’t too confusing!
As I said earlier, I cannot just copy and paste links or ids directly from the website. Apologies, but this also is not helpful. I suggest you re-read the original post to double check the exact stuff I want.
You stated that you wanted to know how to get the “individual package body part IDs from the original package ID.” I gave a method of getting the ids for the individual body parts. My solution was to create a table that contains a table for every existing package, which in turn contains all of the package’s MeshIds. While this actually solves your problem, it’s quite annoying to do.
However, I managed to make a script that can load a package, then grab all of its CharacterMeshes and cache them to a table. Here’s the function for changing the character’s package:
local serverStorage = game:GetService("ServerStorage")
local assetService = game:GetService("AssetService")
local insertService = game:GetService("InsertService")
local cachedPackages = {
}
local function pcallRetry(functopcall,maxRetries)
local success, returned = pcall(functopcall)
local retries = 0
while retries <= maxRetries and success == false do
task.wait(1)
maxRetries += 1
success, returned = pcall(functopcall)
end
assert(success, string.format("Failed to complete request after %s attempts.",maxRetries))
return returned
end
function changeCharMeshes(character,id)
-- check if the char meshes are already cached (cached once used)
local charMeshes = cachedPackages[tostring(id)]
if charMeshes == nil then
charMeshes = {}
local bundleDetails = pcallRetry(function()return assetService:GetBundleDetailsAsync(id)end,3)
for _,itemData in pairs(bundleDetails.Items) do
if itemData.Type == "Asset" and itemData.Id then
local assetModel = pcallRetry(function() return insertService:LoadAsset(itemData.Id)end,3)
local r6 = assetModel:FindFirstChild("R6")
if r6 then
local mesh = r6:FindFirstChildOfClass("CharacterMesh")
if mesh then
table.insert(charMeshes,mesh:Clone())
end
end
assetModel:Destroy()
end
end
cachedPackages[tostring(id)] = charMeshes
end
for _,mesh in pairs(character:GetChildren()) do
if mesh:IsA"CharacterMesh" == false then continue end
mesh:Destroy()
end
for _,mesh in pairs(charMeshes) do
mesh:Clone().Parent = character
end
end
And here’s it running with an admin command (uses the above code, the following function takes a table of players as its first parameter, and the asset id of a package as its second.):
local function packageCMD(plrs, assetId)
for _,v in pairs(plrs) do -- please use pairs when looping through table kthx
local char = v.Character
if char == nil or char.Parent == nil then continue end
changeCharMeshes(char,assetId)
end
end