What do you want to achieve?
I want to apply the players avatar face on a custom character.
What is the issue?
It will not apply the image correctly, instead it will appear as a blank face.
What solutions have you tried so far?
I researched and couldn’t find a right solution.
Here is the code:
local function ChangeChar(player,char)
local humdesc = game.Players:GetHumanoidDescriptionFromUserId(player.UserId)
char.Head:WaitForChild("Face").Texture = "http://www.roblox.com/asset/?id="..tostring(humdesc.Face)
end
Players.PlayerAdded:Connect(function(player)
spawn(function()
player.CharacterAdded:Connect(function(char)
ChangeChar(player,char)
end)
ChangeChar(player,player.Character)
end)
end)
local function ChangeChar(player,char)
local char2 = "CustomCharacter"
char2.Head:WaitForChild("Face").Texture = char:WaitForChild("Head"):WaitForChild("face").Texture
end
Players.PlayerAdded:Connect(function(player)
spawn(function()
player.CharacterAdded:Connect(function(char)
ChangeChar(player,char)
end)
ChangeChar(player,player.Character)
end)
end)
It’s not your issue but FWIW I don’t think “Face” is consistently used as the name. I know it used to be “face”, then I know some new assets changed over time, and now I think both are used occasionally. Check :FindFirstChildWhichIsA("Decal") instead.
The problem isn’t finding the face, I think roblox faces just won’t load from my scripts because there decals are private. So I guess this is unsolvable?
So after a while of testing, I came up with the code, pretty much you get a template dummy and load the players normal avatar onto it if you are using starter characters(it has to be in workspace first then add a “wait()” then put it into a folder to hide it). After that clon the face and remove the face off of the starter character to replace it with the new one.
Code:
local function SetChar(player)
local clon = game.ReplicatedStorage.Template:Clone()
clon.Name = player.Name
clon.Parent = game.Workspace
local humdesc = game.Players:GetHumanoidDescriptionFromUserId(player.UserId)
clon.Humanoid:ApplyDescriptionReset(humdesc)
wait()
clon.Parent = game.ReplicatedStorage.CustomCharacters
return clon
end
local function ChangeChar(player,char)
local id = char.Head:FindFirstChildOfClass("Decal"):Clone()
player.Head:WaitForChild("Face"):Destroy()
id.Parent = player.Head
end
Players.PlayerAdded:Connect(function(player)
local charclon = SetChar(player)
player.CharacterAdded:Connect(function(char)
charclon:Destroy()
charclon = SetChar(player)
ChangeChar(char,charclon)
end)
ChangeChar(player.Character,charclon)
end)
(sorry for being so late I forgot about this post)