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"
end
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.
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"
print("Successful")
end
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"
print("Successful")
end