Issue With Player Entering ID to Image

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I want to Create a TextBox GUI, that the player can enter their asset id in, and it will change an ImageLabel GUI to the id they entered in.

  1. What is the issue? Include screenshots / videos if possible!

The ID Prints 16 when I enter the ID of 4637746375

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I have tried and looked about subtracted from IntValues but I did not understand any of it.

-- Place this code in a LocalScript inside a TextBox
local textBox = script.Parent

-- Initialize the state of the textBox
textBox.ClearTextOnFocus = true
textBox.Text = ""

local function onFocused()
	textBox.Text = ""
end

local function onFocusLost(enterPressed, inputObject)
	if enterPressed then
		local ID = textBox.Text - 1
		local assetlink = "http://www.roblox.com/asset/?id="
		print(ID)
		--ID = - 1
		script.Parent.Parent.Parent.ImageLabel.Image = "http://www.roblox.com/asset/?id=".. ID
	else
		-- The player stopped editing without pressing Enter
		textBox.Text = ""
	end
end

textBox.FocusLost:Connect(onFocusLost)
textBox.Focused:Connect(onFocused)
1 Like

Why the -1 line for the ID? Am I missing something? Also, you address the variable assetlink yet you don’t use it when you change the image.

1 Like

I think the -1 is for getting the template. Not sure if this is still the case.

1 Like

Ahhh yes, ive noticed that when you enter an asset id in normal studio (Not texting or playing mode), the id deletes one

Maybe try converting the text to a number?

local ID = tonumber(textBox.Text) - 1
1 Like

Hmmmm it prints the right number, but doesn’t add the http://www.roblox.com/asset/?id= to the ID

It doesn’t add that to the ID when changing the Image?

Its supposed to but it doesnt for some reason

Maybe try changing that line to

script.Parent.Parent.Parent.ImageLabel.Image = "http://www.roblox.com/asset/?id=".. tostring(ID)

Maybe the ID had to be converted to a string

1 Like

Ive checked the image and for some reason it doesnt even change it. Heres the roblox game link: Here.rbxl (29.0 KB)

The way it tries to convert is kinda problamatic since I copied a decal id I made into the Iamgelabel, it subtracted 40 to get the imageid. Maybe try

script.Parent.Parent.Parent.ImageLabel.Image = "rbxthumb://type=Asset&id="..tostring(ID).."&w=150&h=150"
2 Likes

That worked thank you so much!

1 Like

Glad to be of help to you! If you have anymore issues don’t be afraid to make another post!

1 Like