How would I do this with table.insert?

I’m working on something new, and I’ve run into a problem. I’m working on exploit protection, and I don’t want to make remotes for every single person, so I want to make a table which will hold a username and the tick().

How would I do this?

I was going to use [Player.Name] = tick() but I don’t know how to add that with the script, without having it in the table beforehand.
Any alternatives I could use?


1 Like
Local array = {}

Currently it should save the player as an object, instead of it’s name. You might not need that.

Where do I put tick(), and how would I grab the value?

If you are planning on having this happen when the player joins, I would do this:

local playerTicks = {}

      playerTicks[plr.UserId] = tick()

      playerTicks[plr.UserId] = nil

This will add the player to the dictionary. If you want to simulate a table that can be looped through in order, I recommend this module which would allow you to get the length of a dictionary so it can be looped through numerically.

To reference it, you would simply do lua playerTicks[plr.UserId]

Note - player.Name would work as well, I just prefer ID’s because their unique and have less potential of breaking in some way.


Instead, you can use

local Players = game:GetService(¨Players¨)

--Code here.

This lets you skip the process of turning the value of the player in the table to nil.


Thank you, this worked!

I made it so exploiters can’t spam a remote to get infinite money in a game, but your answer helped.

Thanks alot, I feel a bit dumb for forgetting about this.

Don’t worry, we all forget stuff forgot some random stuff from time to time!

Make sure to mark it as the answer so readers know it’s been answered!

1 Like