How to load certain bundle assets onto player?

local function applyBundle(humanoid, bundleId)
	local bundleInfo = AssetService:GetBundleDetailsAsync(bundleId)
	
	print(bundleInfo)
	
	for _,assets in pairs(bundleInfo.Items) do
		if assets.Type == "Asset" then
			local bundleDesc = humanoid:GetAppliedDescription()
			print(assets.Name)
			bundleDesc.Torso =  assets.Id
			bundleDesc.RightArm = assets.Id
			humanoid:ApplyDescription(bundleDesc)		
		end
	end
end

I’m trying to load the arms, legs and torso part of the bundles onto my character. I don’t want to load in the entire bundle as it will just remove the entire humanoidDescription of the players. I’ve been at this for a while and haven’t come up with anything.

1 Like
local Game = game
local Players = Game:GetService("Players")
local AssetService = Game:GetService("AssetService")
local MarketplaceService = Game:GetService("MarketplaceService")

local AssetTypes = {[17] = "Head", [27] = "Torso", [28] = "RightArm", [29] = "LeftArm", [30] = "LeftLeg", [31] = "RightLeg"}

local function OnPlayerAdded(Player)
	local function OnCharacterAdded(Character)
		if not Player:HasAppearanceLoaded() then Player.CharacterAppearanceLoaded:Wait() end
		local Humanoid = Character:FindFirstChildOfClass("Humanoid")
		if not Humanoid then return end
		local HumanoidDescription = Humanoid:GetAppliedDescription()
		local Success, Result = pcall(AssetService.GetBundleDetailsAsync, AssetService, 192)
		if not Success then warn(Result) return end
		for _, Item in ipairs(Result.Items) do
			Success, Result = pcall(MarketplaceService.GetProductInfo, MarketplaceService, Item.Id)
			if not Success then warn(Result) continue end
			local BodyPart = AssetTypes[Result.AssetTypeId]
			if BodyPart then HumanoidDescription[BodyPart] = Item.Id end
		end
		Humanoid:ApplyDescription(HumanoidDescription)
	end
	
	Player.CharacterAdded:Connect(OnCharacterAdded)
end

Players.PlayerAdded:Connect(OnPlayerAdded)

I’ve used the ‘Korblox’ bundle as an example.

1 Like