Help with table.insert

How do i make table.insert do this

local mytalble = {
  [2] = "eee"
  [3] = "asdas"

what i want to do is make a mining system that is realistic
i want it to do is

local targetsandtheirhealth = {

  [5] = "Brick" -- Brick is object and [5] is the health of the object


table.insert(targetsandtheirhealth,#targetsandtheirhealth+1,[target.Parent.Health] = target)

tall get the idea right so is that possible ? if not is there a alternative to it?

1 Like

using health as index isnt really a good idea but if u wanted to stick to it instead of doing table.insert you should do mytable[health] = “Brick”

you could make it better by making the index the targets name/target itself and assigning it another dictionary or a table which contains the object and health


Use a dictionary which is much easier

local targetDictionary = {
  ["PlayerName"] = {Object = "Brick", Health = 5}

local health = targetDictionary.PlayerName.Health
local object = targetDictionary.PlayerName.Object

nice but how do i do that with table.insert

you cannot, you can just do

dictionary.someKey = someValue


dictionary["someKey"] = someValue
1 Like

damn it then i need to think of another alternative

wait also is it possible to do



No, it is not possible to do so.

1 Like

then bruh i guess i will use values then like
object value and there children a num value

to cause less lag ill cap it

i dont understand why are you having issues, he already proposed an alternative

1 Like

that alternative is not what i need i need a alternative alternative

Idk why roblox is sooooooo limited ya know like yea

1 Like