How do i make an image label change when a text labels text is == to something?

When a text labels text is == to something i want to make it the image label changes but idk why it doesn’t work (btw its a local script inside the image label)

local Gui = game.StarterGui.MainGui2.InventoryGui.Templates.Item
if Gui.ItemName.Text == "Wood" then
	Gui.ImageLabel.Image = "rbxassetid://6421015660"
1 Like

Are you getting any errors, or is the image you are getting just a blank image?

Change the path of the GUI variable to like script.Parent or something like that.

And also, just upload the image on a part and make it a decal, go to the decal’s property and copy the number. Then say:

Gui.ImageLabel.Image = "rbxassetid://" -- And paste the number you copied

the image is just blank and im getting no errors

same happens with the that one no errors or changing image

So that means there is something wrong with the image ID, or you condition is not being met, so make sure that after you check if the text is wood put a print statement to make sure you dont have a logical error. After you check for the logical error do Gui.ImageLabel.Image = “rbxassetid://” … (insert decal id here)

The “Gui” variable shouldn’t be looking under StarterGui, since StarterGui isn’t what a player directly sees. Instead, you should either use script.Parent… or player.PlayerGui… to reference the GUI.

Also what he said, i didn’t even pick that up nice look. You spend so much time not making those errors with startergui and than you look at someone elses code and you dont even seem to notice that haha.

So it does work but the image is just blank?
Screen Shot 2021-02-20 at 9.41.28 PM

As @DryChicken said you are pointing to a instance in StarterGui and not your playerGui, so you want to have the variable in the localscript being like

script.Parent.MainGui2.inventoryGui.Templates.Item, or where your localscript is relative to the item template.

that image was when i changed it to script.Parent like this?

local item2 = script.Parent.Parent
if item1.Text == "Wood" then
	print("Text is working")
	item2.ImageLabel.Image = "rbxassetid://6421015596"

1 got cut off

Here is how the hierarchy would work for a script like this

so if i wanted to get the imagelabel with a variable i would do…

local imageLabel = script.Parent.Item.ImageLabel

So basically like this right?

local ItemLabel = script.Parent.InventoryGui.Templates.Item.ImageLabel
local ItemName = script.Parent.InventoryGui.Templates.Item.ItemName
if ItemName.Text == "Wood" then
	print("Text is working")
	ItemLabel.ImageLabel.Image = "rbxassetid://6421015596"

if so nothing happens it doesn’t even print or give me an error

Yes, but instead of ItemLabel.ImageLabel.Image you would want to do ItemLabel.Image = “rbxassetid”…

this is what happens, like again no errors or prints
Screen Shot 2021-02-20 at 9.57.56 PM

can I see the explorer dropdown of the gui?

yeah sure here
Screen Shot 2021-02-20 at 10.01.55 PM