Type Decal ID in a TextBox display in ImageLabel

Hi,

I was making this customize avatar system
I added this feature where the player can change there face
but I don’t know how to script it

here are my attempts:

local image = script.Parent.AvatarPreview.Head.Image
local textbox = script.Parent.ChangeFace

image.Image = "rbxassetid://" .. textbox.Text

errors:
Image https://assetdelivery.roblox.com/v1/asset?id= failed to load. Error 404: Request asset was not found

thanks in advance :smiley:

It’s giving you that warning because the Text property of the Textbox is likely empty or is not a string, and it’s trying to find an asset with no id

You could listen for when the Text property changes, but I think a better approach would be to change the face when a button is pressed.

Also rbxassetid:// shouldn’t be in this case as it doesn’t convert the given Decal ID into an Image ID, which is what the Image property requires

As a basic example, let’s assume you’re trying to make it so it changes the face when a button is pressed, you can do this

local image = script.Parent.AvatarPreview.Head.Image
local textbox = script.Parent.ChangeFace
local button = --Location of button

button.MouseButton1Down:Connect(function()
	local id = tonumber(textbox.Text)
	if not id then
		return
	end
	image.Image = "rbxthumb://type=Asset&id="..id.."&w=150&h=150"
end)
5 Likes

so what does the texbox do?‎‎‎‎‎‎‎

The textbox’s use is to store the ID of the image the user writes into it so when the button is pressed, it checks the Text of the textbox to get the id to put as the Image

I’m confused on how it works :sweat_smile:
could you explain it for me

Certainly!

When the specified button is pressed, it gets the Text of the given Textbox and converts it to a number via tonumber. This will return 1 of 2 things, the given text as a number, or nil if what was given was not a full number

print(tonumber("5363")) --5363
print(tonumber("56hg")) -- nil

Which is why the if not id then if statement is there, so it checks for nil, but if the text was properly converted, it’ll change the Image using a special url that helps in converting an id into an id suitable for properties that require an image ID

so you type the userid in the textbox then click the button?

The id of the face to put on the preview if you’re trying to make a preview

1 Like

Furthermore, you could apply MarketplaceService methods to determine if it is even an image id at all.