Hello guys! Im trying to make a new code, in workspace I have 4 block from Part1 to Part4. The four blocks are added to the table. The table gets a randomized number from itself, and sets the block at workspace to transparent. My problem is that it is not deleting the data, because im trying to do that if it got the data and set the block to transparent, it needs to delete that data from the table, but it did not did it. Can someone help? Sorry for the bad english, my mother language is not english.
`
local ttable = {"Part1","Part2","Part3","Part4"} local value = math.random(1,#ttable) local pickedvalue = ttable[value] workspace["Part"..value].Transparency = 1 table.remove(ttable, value) print(tostring(value)) for index = 1, #ttable do print(index, ttable[index]) end
`
Thank you!
The code is fine, the problem is that each time you click, you create a new local table containing 4 items. You are not persisting this table in between clicks.
Pull the table outside of the MouseClick event and add an if statement at the beginning of the click listener to check if there's at least 1 item in the table (otherwise math.random will throw an error)