Character Customization Help

I wanted to make this customization thing for my game. But for some reason I am having trouble on changes the eyes

When pressing the arrows to switch the eyes, it does not change the eyes. ( I didn’t add the whole script onto the forum)

	local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")

local module = {}

local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local characterClothing = character:WaitForChild("Clothing")
local characterHead = character:WaitForChild("Head")

local bodyParts = {
	Head = character:WaitForChild("Head"),
	Torso = character:WaitForChild("Torso"),
	["Left Leg"] = character:WaitForChild("Left Leg"),
	["Right Leg"] = character:WaitForChild("Right Leg"),
	["Left Arm"] = character:WaitForChild("Left Arm"),
	["Right Arm"] = character:WaitForChild("Right Arm")
}

local appearanceItemColors = {}

local clothing = ReplicatedStorage.Assets.Clothing

local module = {
	
	--Hair
	Hair = function(currentNumber)
		local hair = clothing.Hair:FindFirstChild(currentNumber)
		if not hair then
			return
		end
		
		for _, lastHair in ipairs(characterClothing.Hair:GetChildren()) do
			lastHair:Destroy()
		end
		
		local hairClone = hair:Clone()
		hairClone.Color = appearanceItemColors.Hair or Color3.fromRGB(255, 255, 255)
		hairClone.CFrame = bodyParts.Head.HairAttachment.WorldCFrame * CFrame.new(hairClone:GetAttribute("Position") or workspace.br8.Value)
		hairClone.Parent = characterClothing.Hair
		
		local weldConstraint = Instance.new("WeldConstraint")
		weldConstraint.Part0 = hairClone
		weldConstraint.Part1 = bodyParts.Head
		weldConstraint.Parent = hairClone
	end,
	
	--Eyes
	Eyes = function(currentNumber)
		local eye = clothing.Eyes:FindFirstChild(currentNumber)
		if not eye then
			return
		end
		
		for _, lastEye in ipairs(characterHead["1"]:GetChildren()) do
			lastEye:Destroy()
		end
		
		local eyeClone = eye:Clone()
		eyeClone = bodyParts.Head
		eyeClone = characterHead
		
		
	end,
	
	--Shoes
	Shoes = function(currentNumber)
		local shoe = clothing.Shoes:FindFirstChild(currentNumber)
		
		for _, lastShoe in ipairs(characterClothing.Shoes:GetChildren()) do
			lastShoe:Destroy()
		end
		
		for _, leg in ipairs({"Right", "Left"}) do
			local legPart = bodyParts[leg .. " Leg"]
			local shoeClone
			
			if shoe and shoe:IsA("MeshPart") then
				shoeClone = shoe:Clone()
			elseif shoe and shoe:IsA("Model") then
				shoeClone = shoe:FindFirstChild(leg):Clone()
			end
			
			shoeClone.Color = appearanceItemColors.Shoes or Color3.fromRGB(255, 255, 255)
			shoeClone.CFrame = legPart:FindFirstChild(leg .. "FootAttachment").WorldCFrame * CFrame.new(0, 0.1, -0.05)
			shoeClone.Parent = characterClothing.Shoes
			
			local weldConstraint = Instance.new("WeldConstraint")
			weldConstraint.Part0 = shoeClone
			weldConstraint.Part1 = legPart
			weldConstraint.Parent = shoeClone
		end
	end,
	
	--Shirt
	Shirt = function(currentNumber)
		local shirt = clothing.Shirt:FindFirstChild(currentNumber)
		if shirt and shirt:IsA("MeshPart") then
			for _, lastPart in ipairs(characterClothing.Shirt:GetChildren()) do
				lastPart:Destroy()
			end
			
			local shirtClone = shirt:Clone()
			shirtClone.Color = appearanceItemColors.Shirt or Color3.fromRGB(255, 255, 255)
			shirtClone.CFrame = bodyParts.Torso.CFrame * CFrame.new(shirtClone:GetAttribute("Position") or Vector3.new())
			shirtClone.Parent = characterClothing.Shirt

			local weldConstraint = Instance.new("WeldConstraint")
			weldConstraint.Part0 = shirtClone
			weldConstraint.Part1 = bodyParts.Torso
			weldConstraint.Parent = shirtClone
		elseif shirt and shirt:IsA("Model") then
			characterClothing.Shirt:Destroy()
			
			local shirtClone = shirt:Clone()
			shirtClone.Name = "Shirt"
			
			for _, part in ipairs(shirtClone:GetChildren()) do
				part.Color = appearanceItemColors.Shirt or Color3.fromRGB(255, 255, 255)
				part.CFrame = bodyParts[part.Name].CFrame * CFrame.new(part:GetAttribute("Position") or Vector3.new())
				
				local weldConstraint = Instance.new("WeldConstraint")
				weldConstraint.Part0 = part
				weldConstraint.Part1 = bodyParts[part.Name]
				weldConstraint.Parent = part
			end
			
			shirtClone.Parent = characterClothing
		end
	end,
	
	--Pants
	Pants = function(currentNumber)
		local pants = clothing.Pants:FindFirstChild(currentNumber)
		if pants and pants:IsA("Model") then
			characterClothing.Pants:Destroy()
			
			local pantsClone = pants:Clone()
			pantsClone.Name = "Pants"
			
			for _, part in ipairs(pantsClone:GetChildren()) do
				part.Color = appearanceItemColors.Pants or Color3.fromRGB(255, 255, 255)
				part.CFrame = bodyParts[part.Name].CFrame * CFrame.new(part:GetAttribute("Position") or Vector3.new())
				
				local weldConstraint = Instance.new("WeldConstraint")
				weldConstraint.Part0 = part
				weldConstraint.Part1 = bodyParts[part.Name]
				weldConstraint.Parent = part
			end
			
			pantsClone.Parent = characterClothing
		end
	end,

image
https://gyazo.com/6706fd060d2dea83151d3839ef0f1ca7

2 Likes

Maybe your forgot to set the parent or the clone

local eyeClone = eye:Clone()
eyeClone.Parent = bodyParts.Head -- .Parent

And idk which is the right head, bodyParts.Head or characterHead ?

1 Like

bodyParts.Head
I have deleted the characterHead part because it wasn’t needed. But I still have the same problem.

1 Like

I finally solved the problem, the faces was not being cloned and the face was not getting deleted. Yet there was no errors.

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