From f4f5fac4800842a1fce444478290504b4307f7ce Mon Sep 17 00:00:00 2001 From: Name <63927092+F2KENAME@users.noreply.github.com> Date: Wed, 15 Apr 2026 17:28:57 +0700 Subject: [PATCH 1/3] Refactor convert.luau for external uses --- src/convert.luau | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/src/convert.luau b/src/convert.luau index 06a49aa..7403681 100644 --- a/src/convert.luau +++ b/src/convert.luau @@ -32,13 +32,7 @@ local function headMeshFromHumanoidDescription(humDesc: HumanoidDescription): nu return meshByName["RobloxClassic"] end -function convert.convertCharacter(humanoid: Humanoid): () - local humDesc = humanoid:GetAppliedDescription() - if humDesc == nil then - warn(`rbx-reface: could not get applied description for {humanoid.Parent.Name}`) - return - end - +function convert.applyHeadDescription(humDesc: HumanoidDescription): () local currentMesh = humDesc.Head local targetMesh = headMeshFromHumanoidDescription(humDesc) local face = faceByMesh[currentMesh] @@ -50,16 +44,10 @@ function convert.convertCharacter(humanoid: Humanoid): () humDesc.Head = targetMesh humDesc.Face = face + return targetMesh, face +end - local ok, err = pcall(function() - humanoid:ApplyDescriptionResetAsync(humDesc) - end) - - if not ok then - warn(`rbx-reface: failed to apply description: {err}`) - return - end - +function convert.fixHeadTexture(humanoid: Humanoid, targetMesh: number): () -- iBot's texture is not correctly restored if targetMesh == meshByName["iBot"] then local head = humanoid.Parent:FindFirstChild("Head") @@ -71,4 +59,25 @@ function convert.convertCharacter(humanoid: Humanoid): () end end +function convert.convertCharacter(humanoid: Humanoid): () + local humDesc = humanoid:GetAppliedDescription() + if humDesc == nil then + warn(`rbx-reface: could not get applied description for {humanoid.Parent.Name}`) + return + end + + local targetMesh = convert.applyHeadDescription(humDesc) + + local ok, err = pcall(function() + humanoid:ApplyDescriptionResetAsync(humDesc) + end) + + if not ok then + warn(`rbx-reface: failed to apply description: {err}`) + return + end + + convert.fixHeadTexture(humanoid, targetMesh) +end + return convert From e07c806300e3d54ce064dc34bdae9ef27ee0976b Mon Sep 17 00:00:00 2001 From: Name <63927092+F2KENAME@users.noreply.github.com> Date: Wed, 15 Apr 2026 21:42:49 +0700 Subject: [PATCH 2/3] function rename and delete unnecessary return fixHeadTexture is renamed to fixiBotTexture applyHeadDescription now only return targetMesh --- src/convert.luau | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/convert.luau b/src/convert.luau index 7403681..c770b17 100644 --- a/src/convert.luau +++ b/src/convert.luau @@ -44,10 +44,10 @@ function convert.applyHeadDescription(humDesc: HumanoidDescription): () humDesc.Head = targetMesh humDesc.Face = face - return targetMesh, face + return targetMesh end -function convert.fixHeadTexture(humanoid: Humanoid, targetMesh: number): () +function convert.fixiBotTexture(humanoid: Humanoid, targetMesh: number): () -- iBot's texture is not correctly restored if targetMesh == meshByName["iBot"] then local head = humanoid.Parent:FindFirstChild("Head") From 1080cf2cacb17274dab862cf43b58115def835f5 Mon Sep 17 00:00:00 2001 From: "Ivy C." Date: Wed, 15 Apr 2026 12:57:19 -0400 Subject: [PATCH 3/3] fix: correct teturn type of `applyHeadDescription` --- src/convert.luau | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/convert.luau b/src/convert.luau index c770b17..9ce911b 100644 --- a/src/convert.luau +++ b/src/convert.luau @@ -32,7 +32,7 @@ local function headMeshFromHumanoidDescription(humDesc: HumanoidDescription): nu return meshByName["RobloxClassic"] end -function convert.applyHeadDescription(humDesc: HumanoidDescription): () +function convert.applyHeadDescription(humDesc: HumanoidDescription): number local currentMesh = humDesc.Head local targetMesh = headMeshFromHumanoidDescription(humDesc) local face = faceByMesh[currentMesh]