Say I was trying to sort out a single value from a table, and match it up with another value from some other script (Like an IntValue, string value.) Would this work, or would I need some modifications?
local TVON = script.Parent["textVal-ObjName"] local tableofItems = { "item1";"item2";"item3";"item4"; } TVON.Changed:connect(function() --when the value changes. local name = TVON.Value if name.Value == tableofItems then --codehere end end)
Here is what you do:
local TVON = script.Parent["textVal-ObjName"] local tableofItems = { "item1","item2","item3","item4"} TVON.Changed:connect(function(value) --when the value changes. local p = TVON[value] if value == "Value" then -- I didn't check with p, because it might cause a bug #SafetyFirst for _,v in pairs (tableofitems) do local name = tostring(p) if name == v then -- code end end end end)
That should work. Let me explain it:
The local 'p' gets the property of 'TVON' that changed.
The 'value' is the property that changed. It checks to see if 'value' is called "Value", then goes through the table's items, checking to see if one of them is the same as 'p' s value.
The tostring gets the value of 'p'.