Load Player Assets to StarterCharacter

I’m using a StarterCharacter for my experience, and I’m wondering how to load the players’ hats to it? I’ve searched on the dev forum already, but I’m unable to find the answer I’m looking for.

You would attach accessories to the StarterCharacter model the same way you would with any model which contains a “Humanoid” instance.

1 Like

I want to load the players avatar assets to a startercharacter, I want to know how to get what they’re wearing to actually attach the accessories.

1 Like

Just decided to tackle this and write a script for it, it’s working well on my end.

local players = game:GetService("Players")
local insert = game:GetService("InsertService")

local protectedCall = pcall

local function onPlayerAdded(player)
	local function onCharacterAdded(character)
		local humanoid = character:WaitForChild("Humanoid")
		local success1, result1 = protectedCall(function()
			return players:GetCharacterAppearanceInfoAsync(player.UserId)
		end)
		
		if success1 then
			if result1 then
				for _, array in ipairs(result1["assets"]) do
					if array["assetType"]["name"] == "Hat" or array["assetType"]["name"]:match("Accessory$") then
						local success2, result2 = protectedCall(function()
							return insert:LoadAsset(array["id"])
						end)
						
						if success2 then
							if result2 then
								local accessory = result2:FindFirstChildOfClass("Accessory")
								if accessory then
									humanoid:AddAccessory(accessory)
								end
							end
						else
							warn(result2)
						end
					end
				end
			end
		else
			warn(result1)
		end
	end
	player.CharacterAdded:Connect(onCharacterAdded)
end

players.PlayerAdded:Connect(onPlayerAdded)

I tested using Roblox’s “Drooling Zombie” model as a StarterCharacter. Here’s the reproduction file.

repro.rbxm (29.4 KB)

4 Likes

So you can make script for Shirt and Pants for StarterCharacter?