I'm using this in a singleplayer game. It works in solo mode and server in studio, but not in an actual server. Everything but the shirt and pants appear. Is the loading time of a character even important in getting this to work properly?
game.Players.PlayerAdded:connect(function(p)
p.CharacterAdded:connect(function(c)
wait(3)
for i,v in pairs(c:GetChildren()) do
if v:IsA("Hat") then
v:remove()
end
if v:IsA("CharacterMesh") then
v:remove()
end
end
local q = game.ServerStorage.MessySpikes:clone()
c.Head.face.Texture = "http://www.roblox.com/asset/?id=13038247"
q.Parent = c
for i,v in pairs(c:GetChildren()) do
if v:IsA("Part") then
v.BrickColor = BrickColor.new("Pastel brown")
end
end
local r = c:FindFirstChild("Shirt")
if r ~= nil then
r.ShirtTemplate = "rbxassetid://150565172"
else
local y = Instance.new("Shirt")
y.Parent = c
y.ShirtTemplate = "rbxassetid://150565172"
end
local m = c:FindFirstChild("Pants")
if m ~= nil then
m.PantsTemplate = "rbxassetid://150515287"
else
local t = Instance.new("Pants")
t.Parent = c
t.PantsTemplate = "rbxassetid://150515287"
end
end)
end)

3 comments
Try setting "CanLoadCharacterAppearance" to false then loading all of your assets when the character loads. More information on the Player page in the wiki.
Also you could use CharacterLoaded in a nested function.
CanLoadCharacterAppearance worked great! Thank you very much!