Need help with Roblox Character Textures

So I’ve created a litte script to turn every body part into editable meshes.

local LocalPlayer = game:GetService("Players").LocalPlayer
local AssetService = game:GetService("AssetService")
local Aliases = {LeftArm = "Left Arm", RightArm = "Right Arm", LeftLeg = "Left Leg", RightLeg = "Right Leg"}
local BodyParts = {
	Head = {
		Default = "heads/head"
	},
	Torso = {
		Default = "meshes/torso",
		Clothing = "Shirt"
	},
	["Left Arm"] = {
		Default = "meshes/leftarm",
		Clothing = "Shirt"
	},
	["Right Arm"] = {
		Default = "meshes/rightarm",
		Clothing = "Shirt"
	},
	["Left Leg"] = {
		Default = "meshes/leftleg",
		Clothing = "Pants"
	},
	["Right Leg"] = {
		Default = "meshes/rightleg",
		Clothing = "Pants"
	}
}

LocalPlayer.CharacterAdded:Connect(function(character)
	local overrideMesh = {}
	
	for _, characterMesh in pairs(character:GetChildren()) do
		if characterMesh:IsA("CharacterMesh") then
			local name = characterMesh.BodyPart.Name
			if Aliases[name] then
				name = Aliases[name]
			end
			overrideMesh[name] = "rbxassetid://"..characterMesh.MeshId
			characterMesh:Destroy()
		end
	end
	
	for name, value in pairs(BodyParts) do
		local part : Part = character:WaitForChild(name)
		part.Transparency = 1
		
		local id = overrideMesh[name] or "rbxasset://avatar/"..value.Default..".mesh"
		local textureId
		
		if value.Clothing then
			if value.Clothing == "Shirt" then
				textureId = character:FindFirstChildWhichIsA("Shirt").ShirtTemplate
			else
				textureId = character:FindFirstChildWhichIsA("Pants").PantsTemplate
			end
		end
		
		if name == "Head" then
			local face = part:WaitForChild("face") :: Decal
			face.Transparency = 1
			textureId = face.Texture
		end
		
		local meshHolder = Instance.new("MeshPart")
		meshHolder.Size = Vector3.new(1, 1, 1)
		local weld = Instance.new("Weld")
		weld.Part0 = part
		weld.Part1 = meshHolder
		weld.Parent = meshHolder
		
		local mesh = AssetService:CreateEditableMeshAsync(id)
		mesh.Parent = meshHolder
		
		local texture = AssetService:CreateEditableImageAsync(textureId)
		texture.Parent = meshHolder
		
		meshHolder.Parent = workspace
	end
end)

The meshes look normal, But all textures are in the wrong place:

PixPin_2024-01-05_03-43-29
PixPin_2024-01-05_03-51-55

Is there a way to convert Shirt/Pants Templates and Face into the actual character texture?

u need to UV unwrap the Meshes with the Shirt Template in Blender or any other 3D modelling Software.

I was converting existing body parts into Editable mesh, So i couldn’t UV map them. But I’ve already solved it, Just combine the shirt and pants templates into the actual character texture using Editable Image, Then apply the combined texture. (Texture Reference)

1 Like

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