How would I find the texture of a face with a script?

I’m trying to make a donator perk UI similar to @TheFurryFish’s Basic Admin Donator Perks, and I’m wondering how would I get the asset id/texture of the face when the face id is entered.

User enters faceid from catalog → Script finds the texture/asset id of the face → Script changes face to new face - How would I accomplish this? Any help is appreciated.image

3 Likes

Do you mean how you would fire the event to the server and change the player’s face? As in, do you need to know how the commands work in the UI or just applying the texture?

1 Like

I need to get the texture id of the face. For example, user enters: 494291269 – Face ID, how would I get this: 494290547 – Texture ID, from it.

Using textbox.text Perhaps?

30chars

2 Likes

I’m not trying to get the thing they have entered. I’m trying to get the texture id, from a face id being entered. As roblox uses texture IDs instead of actual catalog face ids for faces in games.

So using InsertService, you can get any asset from the catalog and put them in the studio, this applies for accessories and faces. The LoadAsset function returns a model containing the Instance from the asset. In this case, putting a face Id will return a model containing a Decal with the ImageID.

In conclusion:

local InsertService = game:GetService("InsertService")

function GetFaceImage(FaceID) --the ID from the catalog
    local AssetModel = InsertService:LoadAsset(FaceID)
    if AssetModel then
        return AssetModel:FindFirstChildOfClass("Decal").Texture --the ImageID for the face
    end
end

use InsertService:LoadAsset for that

local face = 8329679
local faceId = game:GetService("InsertService"):LoadAsset(face).face.Texture

I hope this site explains you what you need, you also can use the Name instead of the ID, and then COMPARE the id with all the id of the array and return a decal if both id‘s matches.

Ah yes this is an interesting one. You could do something such as a repeat loop until you find a texture, but that wouldn’t be very accurate.

So, use the server and call a remote function to get it.

Put this code inside a script in ServerScriptService

Then from the client, Invoke the remotefunction and it will return the id or nil, depending on whether or not the ID is valid.

You can read more about InvokeServer in the link above if you’re unsure how it works

@lexishh, i hope this can work:

Thanks this function, you can also get the TextureID thanks a simple object ID, see more on the second link

Unfortunatley this didn’t work for me.

I’ll try it in a minute if the others don’t work.

1 Like

I’ll see if this works for me. Thanks!

All InsertService answers just come to an int64 error. I’m confused.

Show us the error, else we can‘t help

image

you need to put a number, not a string.

what you did :
id = "1337"

what you need to do :
id = 1337

I’m using the user’s input, through a textbox, It’s a number though.

Use tonumber() to convert it to a number

2 Likes

image Like this?