Character Customization faces failed to load

I made a Character Customization so players can edit their avatar in-game but the face feature doesn’t seem to work. I made an ImageButton and a local script inside it. Here’s the script:

Code
    script.Parent.MouseButton1Click:Connect(function()
    local Character = game.Players.LocalPlayer.Character
    local head = Character:WaitForChild("Head")
    head.face.Texture = 'rbxassetid://31117267'

end)

In the output , it said:

Image “https://assetgame.roblox.com/asset/?id=255827175” failed to load in “Workspace.MinuhaYT.Head.face.Texture”: Failed to resolve texture format | 3c 72 6f 62 6c 6f 78 20 78 6d 6c 6e 73 3a 78 6d 69 6d 65 3d 22 68 74 74 70 3a 2f 2f 77 77 77 2e 77 33 2e 6f 72 67 2f 32 30 30 35 2f 30 35 2f 78 6d 6c 6d 69 6d 65 22 20 78 6d 6c 6e 73 3a 78 73 <roblox xmlns:xmime=“http://www.w3.org/2005/05/xmlmime” xmlns:xs
Here’s a image of it:


Can someone see what’s the problem? The error seem messy.
Also, this is my first time posting here so I’m sorry if I made any mistake. Thanks for your help!!

2 Likes

This is happening because you’re trying to apply a catalog ID to a texture, not an asset ID.

Your buttons already seem to have the proper texture for a face asset, so instead of hard-coding the ID you can set the texture of the face to the ImageButton’s image. This will also allow you to create new face options just by setting the ImageButton’s image, which is very scalable for your use case.

local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function ()
    local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
    local Head = Character:WaitForChild("Head")

    Head.face.Texture = script.Parent.Image
end)
3 Likes

Thanks for answering! I haven’t tested it but it might work!

1 Like