Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to remove a specific value from a table without knowing its order?

I have an inventory (GUI) and inside the inventory has a bunch of other stuff, including a script that I wanted to remove when using :GetChildren(). How do I remove it while only know it's name, since I don't know how the order work when using :GetChildren().

I have also tried table.remove(extable, 1) for a bunch of other :GetChildren(), but I wanted to update them all to current standard in case of error like this. Thanks

1 answer

✓ Accepted answer

You can't remove the right specific value from a table if you don't know where it is. But, if you know what it is, then you can use that to find it. Then you can remove it.

Make use of table.find.

Example:

I want to find a Number, 9235. I know it is 9235. Let's pretend, we do not know where it is.

local NumberTable = {182,36,246468,22235,574,2246,2368,346547,
23526488,967964,263,236747,2353787,2463737575,77949537,4277,
34725,53625756734,44346,34636,3463636,685873,57573,57357,
357373,57,57683523,4234243658,69,67,45,235,37568568,567,
35,2,52,63,74,7,357,37,367,3,9235,235263,645,73,62,452,5,
246,35,745,7,47,45,74,74,7,35,32,52,646,86,9,95,63,52,2875}


-- Using "table.find", I can find which number place, 9235 is on.
-- "table.find" returns a number.

local numberPlace = table.find(NumberTable,9235) -- returns 43

-- Now that we have the numbler place of 9235.
--We can remove it from the table.

table.remove(NumberTable,numberPlace)

This discussion is preserved as it was. New answers, comments, and votes are closed.