Cannot change Character

I am currently making a Character Customization Menu, but I cannot change the player’s character for some odd reason. The script is a Script inside of ServerScriptServer.

function LoadPlayer(Player)
	print("LoadPlayer")
	local Color = Player.CharEditor.Color.Value
	local PantNum = Player.CharEditor.Pants.Value
	local ShirtNum = Player.CharEditor.Shirts.Value

	if ShirtNum == "1" then
		local char = Player.Character
		char:FindFirstChild("Shirt").ShirtTemplate = "http://www.roblox.com/asset/?id=404851338" 
	elseif ShirtNum == "2" then
		local char = Player.Character
		char:FindFirstChild("Shirt").ShirtTemplate = "http://www.roblox.com/asset/?id=170488164" 
	elseif ShirtNum == "3" then
		local char = Player.Character
		char:FindFirstChild("Shirt").ShirtTemplate = "http://www.roblox.com/asset/?id=121612315"
	elseif ShirtNum == "4" then
		local char = Player.Character
		char:FindFirstChild("Shirt").ShirtTemplate = "http://www.roblox.com/asset/?id=162011443" 
	elseif ShirtNum == "5" then
		local char = Player.Character
		char:FindFirstChild("Shirt").ShirtTemplate = "http://www.roblox.com/asset/?id=128491510" 
	elseif ShirtNum == "6" then
		local char = Player.Character
		char:FindFirstChild("Shirt").ShirtTemplate = "http://www.roblox.com/asset/?id=147445001" 
	elseif ShirtNum == "7" then
		local char = Player.Character
		char:FindFirstChild("Shirt").ShirtTemplate = "http://www.roblox.com/asset/?id=2894287601" 
	elseif ShirtNum == "8" then
		local char = Player.Character
		char:FindFirstChild("Shirt").ShirtTemplate = "http://www.roblox.com/asset/?id=5092540626" 
	elseif ShirtNum == "9" then
		local char = Player.Character
		char:FindFirstChild("Shirt").ShirtTemplate = "http://www.roblox.com/asset/?id=5309295347" 
	elseif ShirtNum == "10" then
		local char = Player.Character
		char:FindFirstChild("Shirt").ShirtTemplate = "http://www.roblox.com/asset/?id=5309295347" 
	end

	if PantNum == "1" then
		local char = Player.Character
		char:FindFirstChild("Pants").PantsTemplate = "http://www.roblox.com/asset/?id=2151988427"  
	elseif PantNum == "2" then
		local char = Player.Character
		char:FindFirstChild("Pants").PantsTemplate = "http://www.roblox.com/asset/?id=2679496243" 
	elseif PantNum == "3" then
		local char = Player.Character
		char:FindFirstChild("Pants").PantsTemplate = "http://www.roblox.com/asset/?id=6137040403" 
	elseif PantNum == "4" then
		local char = Player.Character
		char:FindFirstChild("Pants").PantsTemplate = "http://www.roblox.com/asset/?id=1310089742"  
	elseif PantNum == "5" then
		local char = Player.Character
		char:FindFirstChild("Pants").PantsTemplate = "http://www.roblox.com/asset/?id=146497046" 
	end

	if Color == "PastelBrown" then
		local x = BrickColor.new("Pastel brown")
		local char = Player.Character

		char.Head.BrickColor = x
		char.UpperTorso.BrickColor = x
		char["RightLowerArm"].BrickColor = x
		char["LeftLowerArm"].BrickColor = x
		char["RightLowerLeg"].BrickColor = x
		char["LeftLowerLeg"].BrickColor = x
		char["RightUpperArm"].BrickColor = x
		char["LeftUpperArm"].BrickColor = x
		char["RightUpperLeg"].BrickColor = x
		char["LeftUpperLeg"].BrickColor = x
		char["RightFoot"].BrickColor = x
		char["LeftFoot"].BrickColor = x
		char["RightHand"].BrickColor = x
		char["LeftHand"].BrickColor = x
	elseif Color == "BrownYellowishOrange" then
		local x = BrickColor.new("Br. yellowish orange")
		local char = Player.Character

		char.Head.BrickColor = x
		char.UpperTorso.BrickColor = x
		char["RightLowerArm"].BrickColor = x
		char["LeftLowerArm"].BrickColor = x
		char["RightLowerLeg"].BrickColor = x
		char["LeftLowerLeg"].BrickColor = x
		char["RightUpperArm"].BrickColor = x
		char["LeftUpperArm"].BrickColor = x
		char["RightUpperLeg"].BrickColor = x
		char["LeftUpperLeg"].BrickColor = x
		char["RightFoot"].BrickColor = x
		char["LeftFoot"].BrickColor = x
		char["RightHand"].BrickColor = x
		char["LeftHand"].BrickColor = x
	elseif Color == "ReddishBrown" then
		local x = BrickColor.new("Reddish brown")
		local char = Player.Character

		char.Head.BrickColor = x
		char.UpperTorso.BrickColor = x
		char["RightLowerArm"].BrickColor = x
		char["LeftLowerArm"].BrickColor = x
		char["RightLowerLeg"].BrickColor = x
		char["LeftLowerLeg"].BrickColor = x
		char["RightUpperArm"].BrickColor = x
		char["LeftUpperArm"].BrickColor = x
		char["RightUpperLeg"].BrickColor = x
		char["LeftUpperLeg"].BrickColor = x
		char["RightFoot"].BrickColor = x
		char["LeftFoot"].BrickColor = x
		char["RightHand"].BrickColor = x
		char["LeftHand"].BrickColor = x
	elseif Color == "BrickYellow" then
		local x = BrickColor.new("Brick yellow")
		local char = Player.Character

		char.Head.BrickColor = x
		char.UpperTorso.BrickColor = x
		char["RightLowerArm"].BrickColor = x
		char["LeftLowerArm"].BrickColor = x
		char["RightLowerLeg"].BrickColor = x
		char["LeftLowerLeg"].BrickColor = x
		char["RightUpperArm"].BrickColor = x
		char["LeftUpperArm"].BrickColor = x
		char["RightUpperLeg"].BrickColor = x
		char["LeftUpperLeg"].BrickColor = x
		char["RightFoot"].BrickColor = x
		char["LeftFoot"].BrickColor = x
		char["RightHand"].BrickColor = x
		char["LeftHand"].BrickColor = x
	end
	print(Color)
	print(PantNum)
	print(ShirtNum)
	print("Done")
end

Everything is printing properly, but I cannot change the player’s character for some odd reason.

You can’t directly change the id of the shirt. I know, it sucks. You need to use InsertService:LoadAsset(shirtid) and then add the shirt inside the character.

InsertService:LoadAsset (roblox.com)

2 Likes

I have a question so would I do this? And also why wouldn’t I be able to change the character’s color?

local assetId = 1310089742
game:GetService("InsertService"):LoadAsset(assetId)

char:FindFirstChild("Pants").PantsTemplate = assetId
1 Like
if char:FindFirstChild("Shirt") then
	char:FindFirstChild("Shirt"):Destroy()
	local shirtClone = shirt.Clone()
	shirtClone.Parent = character
end

You can change the shirt by doing this also. The “ShirtTemplate” property of a shirt of the player’s character is locked (can not be assigned to).

1 Like

You can change the colors of body parts by doing the following:

local players = game:GetService("Players")
local player = players.LocalPlayer or players.PlayerAdded:Wait()
local character = player.Character or player.CharacterAdded:Wait()
local bodyColors = character:WaitForChild("Body Colors")

bodyColors.HeadColor3 = Color3.new(1, 1, 1)

Bit more info:

1 Like