Can someone help me with TextBox?

Howdy,
I know im dumb for asking this but i want to make it like this, so you put the ID of the badge in the TextBox and then the info appears, but i dont know how to get the text from the textbox. Can someone help me? ( i know it doesnt have sense im doing to to learn some more stuff. )

local BadgeService = game:GetService("BadgeService")

local ID = "The ID from Textbox here"


local info = BadgeService:GetBadgeInfoAsync(ID)

local Icon = script.Parent.BadgeIcon

Icon.Image = "rbxassetid://"..info.IconImageId

script.Parent.BadgeName.Text = info.Name
script.Parent.BadgeDescription.Text = info.Description
1 Like

Just to check, is this all in a local script?

But if you just want to know what is in it, add print(‘text from textbox here’). Also make sure you can see the output menu.

yea i just wanted it to show basic info (name, icon, desc)
like ur just putting the id of the badge and thats it

Can you send me a picture of the explorer please? I am a bit confused to what is going on.

image

there

This should work:

local ID
script.Parent.TextBox.FocusLost:Connect(function(enterPressed)
    if enterPressed then
        ID = script.Parent.TextBox.Text
    end
end)

You can understand more about this script from here: Oops!

And before getting the info from the ID, make sure that ID is not nil, so that we know that the player has entered some text in the textbox. Also make sure that the ID he entered is only composed of digits using the tonumber(ID) function which will return nil if ID has letters or symbols in it.

Theres one error in the output (its nil but as i said i need to learn this better) Can you tell me what to do? : image
(Line 14 is the “local info”)

local BadgeService = game:GetService("BadgeService")

local ID
script.Parent.TextBox.FocusLost:Connect(function(enterPressed)
	if enterPressed then
		ID = script.Parent.TextBox.Text
	end
end)


local info = BadgeService:GetBadgeInfoAsync(ID)

local Icon = script.Parent.BadgeIcon

Icon.Image = "rbxassetid://"..info.IconImageId

script.Parent.BadgeName.Text = info.Name
script.Parent.BadgeDescription.Text = info.Description

This tries to call GetBadgeInfoAsync on ID, which is a nil value.

Try replacing this with

local enterPressed = script.Parent.TextBox.FocusLost:Wait()

That would limit it to being used only one time, but if you’d like it to repeat, try this instead:

local BadgeService = game:GetService("BadgeService")

local ID
script.Parent.TextBox.FocusLost:Connect(function(enterPressed)
	if enterPressed then
		ID = script.Parent.TextBox.Text
local info = BadgeService:GetBadgeInfoAsync(ID)

local Icon = script.Parent.BadgeIcon

Icon.Image = "rbxassetid://"..info.IconImageId

script.Parent.BadgeName.Text = info.Name
script.Parent.BadgeDescription.Text = info.Description

	end
end)

2 Likes

Thanks! This does work but only first time, when the first badge appears its not changing to other one when im putting other ID, how can I fix it?

I made an edit. Check if my attached script works.

Everything works perfectly now, thanks!

Alright. You are advised to mark that as the solution if that helped you.

1 Like