Help: It turns the player color to black when I apply new HumanoidDescription


script in serverscriptservice (it’s only the part it in the video):

changeAvatarTypeEvent.OnServerEvent:Connect(function(plr: Player, Description: HumanoidDescription, head)
	local character = plr.Character
	local Humanoid = character:WaitForChild("Humanoid",1)
	if Humanoid:IsA("Humanoid") then
		local descriptionClone = Humanoid:GetAppliedDescription()
		if head.Value == true then
			descriptionClone.Head = Description.Head
			descriptionClone.RightLeg = Description.RightLeg
			descriptionClone.RightArm = Description.RightArm
			descriptionClone.LeftArm = Description.LeftArm
			descriptionClone.LeftLeg = Description.LeftLeg
			descriptionClone.Torso = Description.Torso
		elseif head.Value == false then
			descriptionClone.Head = Description.Head
			descriptionClone.RightLeg = Description.RightLeg
			descriptionClone.RightArm = Description.RightArm
			descriptionClone.LeftArm = Description.LeftArm
			descriptionClone.LeftLeg = Description.LeftLeg
			descriptionClone.Torso = Description.Torso
		end
		Humanoid:ApplyDescription(descriptionClone)
	end
end)

script in localscript on the button:

local player = game.Players.LocalPlayer
local character = player.Character
local humanoid = character:WaitForChild('Humanoid')
local replicatedstorage = game.ReplicatedStorage
local frame = script.Parent
local changeAvatarTypeEvent = replicatedstorage.ChangeAvatarType

for p,v in pairs(frame:GetChildren()) do
	if v:IsA("GuiButton") then
		v.MouseButton1Down:Connect(function()
			local description = replicatedstorage.Customization.AvatarTypes:WaitForChild(v.ID.Value)
			changeAvatarTypeEvent:FireServer(description, v.Head)
		end)
	end
end

IMPORTANT:

image
The startercharacter has no HumanoidDescription so it can be the problem with that
But I need a solution

full script:

local replicatedStorage = game:GetService("ReplicatedStorage")

local changeFaceEvent = replicatedStorage.ChangeFace
local changeShirtEvent = replicatedStorage.ChangeShirt
local changePantsEvent = replicatedStorage.ChangePants
local changeHairEvent = replicatedStorage.ChangeHair
local changeHatEvent = replicatedStorage.ChangeHat
local changeBundleEvent = replicatedStorage.ChangeBundle
local changeAvatarTypeEvent = replicatedStorage.ChangeAvatarType

changeFaceEvent.OnServerEvent:Connect(function(plr, Image)
	local char = plr.Character
	char.Head.face.Texture = Image
end)

changeShirtEvent.OnServerEvent:Connect(function(plr, Image)
	local char = plr.Character
	char.Shirt:remove()
	local newshirt = Image:Clone()
	newshirt.Parent = char
end)

changePantsEvent.OnServerEvent:Connect(function(plr, Image)
	local char = plr.Character
	char.Pants:remove()
	local newpants = Image:Clone()
	newpants.Parent = char
end)

changeHairEvent.OnServerEvent:Connect(function(plr, Hair)
	local char = plr.Character
	for i,v in pairs(char:GetChildren()) do
		if v:IsA("Accessory") then
			if v.AccessoryType == Enum.AccessoryType.Hair then
				v:Destroy()
			end
		end
	end
	local hairClone = Hair:Clone()
	hairClone.Parent = char
end)

changeHatEvent.OnServerEvent:Connect(function(plr, Hat)
	local char = plr.Character
	for i,v in pairs(char:GetChildren()) do
		if v:IsA("Accessory") then
			if v.AccessoryType == Enum.AccessoryType.Hat then
				v:Destroy()
			end
		end
	end
	local hatClone = Hat:Clone()
	hatClone.Parent = char
end)

changeBundleEvent.OnServerEvent:Connect(function(plr, Description)
	local character = plr.Character
	local Humanoid = character:WaitForChild("Humanoid",1)
	local descriptionClone = Humanoid:GetAppliedDescription()
	Humanoid:ApplyDescription(Description)
end)

changeAvatarTypeEvent.OnServerEvent:Connect(function(plr: Player, Description: HumanoidDescription, head)
	local character = plr.Character
	local Humanoid = character:WaitForChild("Humanoid",1)
	if Humanoid:IsA("Humanoid") then
		local descriptionClone = Humanoid:GetAppliedDescription()
		if head.Value == true then
			descriptionClone.Head = Description.Head
			descriptionClone.RightLeg = Description.RightLeg
			descriptionClone.RightArm = Description.RightArm
			descriptionClone.LeftArm = Description.LeftArm
			descriptionClone.LeftLeg = Description.LeftLeg
			descriptionClone.Torso = Description.Torso
		elseif head.Value == false then
			descriptionClone.Head = Description.Head
			descriptionClone.RightLeg = Description.RightLeg
			descriptionClone.RightArm = Description.RightArm
			descriptionClone.LeftArm = Description.LeftArm
			descriptionClone.LeftLeg = Description.LeftLeg
			descriptionClone.Torso = Description.Torso
		end
		Humanoid:ApplyDescription(descriptionClone)
	end
end)

Make sure all properties, including BodyColor, are properly set in your Description.

changeAvatarTypeEvent.OnServerEvent:Connect(function(plr: Player, Description: HumanoidDescription, head)
	local character = plr.Character
	local Humanoid = character:WaitForChild("Humanoid",1)
	if Humanoid:IsA("Humanoid") then
		local descriptionClone = Humanoid:GetAppliedDescription()
		
		-- This keeps original body color
		Description.BodyColor = descriptionClone.BodyColor
		
		if head.Value == true then
			descriptionClone.Head = Description.Head
			descriptionClone.RightLeg = Description.RightLeg
			descriptionClone.RightArm = Description.RightArm
			descriptionClone.LeftArm = Description.LeftArm
			descriptionClone.LeftLeg = Description.LeftLeg
			descriptionClone.Torso = Description.Torso
		elseif head.Value == false then
			descriptionClone.Head = Description.Head
			descriptionClone.RightLeg = Description.RightLeg
			descriptionClone.RightArm = Description.RightArm
			descriptionClone.LeftArm = Description.LeftArm
			descriptionClone.LeftLeg = Description.LeftLeg
			descriptionClone.Torso = Description.Torso
		end
		Humanoid:ApplyDescription(descriptionClone)
	end
end)
1 Like

Works, thank you so much

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