i made an inventory gui with string values in it, when i click one of the slots it changes the string value in it but it wont change anymore, so if i remove the item in the slot, the value stays the same and wont change.
this is a part of the script to make you understand what it should do...
function OnClicked() local item = script.Parent.Parent.Parent.ItemName.Value local itemC = script.Parent.Parent.Parent.ItemClass.Value local itemA = script.Parent.Parent.Parent.ItemAmount.Value if item == "None" then item = "Test" itemC = "Testing" itemA = "1" elseif item == "Test" then item = "None" itemC = "None" itemA = "0" end end
thats just an example of what it looks..
ps: this is in a local script
I remember making this exact error myself. You are setting the actual value of the StringValue as your variables, not the actual Instance itself. So what you are doing is this:
item = "None"
instead of
item = script.Parent.Parent.Parent.ItemName
Kind of confusing. To fix this, set your variables to the Instances and not the values, and then change all things in your script that says "item" to "item.Value".
Take a look:
function OnClicked() local item = script.Parent.Parent.Parent.ItemName local itemC = script.Parent.Parent.Parent.ItemClass local itemA = script.Parent.Parent.Parent.ItemAmount if item.Value == "None" then item.Value = "Test" itemC.Value = "Testing" itemA.Value = "1" elseif item.Value == "Test" then item.Value = "None" itemC.Value = "None" itemA.Value = "0" end end
I know it's a pain, but it is what it is.