local data = {}
data[1628639350.505] = {}
data[1628639350.505][*pretend this is a random UserId*] = {position = *the position of the player*}
print(data)
table.remove(data, 1628639350.505)
print(data) --- still prints the same
{
[1628639350.505] = ▼ {
[862984790] = ▼ {
["position"] = -0.0742913038, 4, -1.20821118
}
},
}
You have created a dictionary when you set the value of the playerUserId key to an empty table. Therefore you wouldn’t be able to use the table.remove() because the data variable isn’t a table it is a dictionary. To remove a key from a dictionary set the value of the key to nil so in this case for you that would look like:
‘’’
data[1628639350.505] = nil
‘’’
Read here for more info on tables and dictionaries: Tables
Remember to mark this post as a solution if it worked!
Sorry, I posted this just before I went to sleep and from reading some of the posts regarding table.remove vs setting the index’s value to nil, i was reluctant in using the second method, but it seems like I have to anyway. Thanks for the explanation.
Just like you cannot use table.remove() on a dictionary you cannot use brackets on a table to change a value. To change a value in a table you can find its index using table.find() then using this index use table.remove() to remove the value in that index. And insert using table.insert() the new value back into the same index. Like before refer to the Tables API to learn to manipulate tables