Outfit system not working (Reposted due to no one seeing it)

I’m making a character load system (get a person saved outfits, the load them in). The attachments are weird, and stuff just isn’t working correctly.

The code is:

local HttpService = game:GetService('HttpService')

local userId = 852714607

local function makeRequest(link)
	local response = HttpService:GetAsync(link)
	local decodedResponse = HttpService:JSONDecode(response)
	return decodedResponse
end
local function capitalizeFirstLetter(str, addAtEnd)
	if addAtEnd ~= nil then
		return str:sub(1, 1):upper() .. str:sub(2) .. addAtEnd
	end
end

local getOutFits = "https://avatar.roproxy.com/v1/users/" .. userId .. "/outfits"

local outfitsResponse = makeRequest(getOutFits)

local charModel = Instance.new('Model')

local humanoid = Instance.new('Humanoid')
local description = Instance.new('HumanoidDescription')

description.Parent = humanoid
humanoid.Parent = charModel

if outfitsResponse and outfitsResponse.data then
	local getRandomOutfit = outfitsResponse.data[8] --outfitsResponse.data[math.random(1, #outfitsResponse.data)]

	local getOutFitDetails = "https://avatar.roproxy.com/v1/outfits/" .. getRandomOutfit.id .. "/details"
	local detailRequest = makeRequest(getOutFitDetails)
	if detailRequest then
		print(detailRequest)

		charModel.Name = detailRequest.name
		for name, color in pairs(detailRequest.bodyColors) do
			local colorIndex = BrickColor.new(detailRequest.bodyColors[name]).Color
			local fixedName = capitalizeFirstLetter(string.split(name, "Color")[1], "Color")

			description[fixedName] = colorIndex
		end

		for value, scale in pairs(detailRequest.scale) do
			local proportionScaled = capitalizeFirstLetter(value, "Scale")
			description[proportionScaled] = scale
		end

		for _, asset in pairs(detailRequest.assets) do
			local assetId = asset.id
			local assetType = asset.assetType.name

			game:GetService('InsertService'):LoadAsset(assetId):GetChildren()[1].Parent = charModel
			description[assetType] = assetId
		end

	end
end

charModel.Parent = workspace
humanoid:ApplyDescriptionReset(description)
wait(0.5)
charModel.PrimaryPart = charModel:FindFirstChild('Torso') or charModel:FindFirstChild('HumanoidRootPart')

local characterPosition = Vector3.new(0,charModel:GetModelSize().Y/2,0)
charModel:PivotTo(CFrame.new(characterPosition))

for _, part in pairs(charModel:GetDescendants()) do
	if part:IsA('BasePart') then
		part.Locked = false
		part.Anchored = true
	end
end

Is this post what you are looking to achieve?

Yes! I can’t believe I was manually creating everything. This worked, but one solution I did find was just applying the humanoid description to a premade rig.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.