If ID is used then you can't take it

Hi,

I have a updating vehicle number.
But i only want 1 copy of a number ingame.
I also have a random ID picker.

So when a number (ID) is used on a vehicle, then on the random ID picker, that ID that is used, you can’t get anymore picked randomly to be visible.

Sorry for my bad english, if you dont understand i can explain it more detailed.

Thanks for anyone for helping!

1 Like

You can do this by adding a table like local usedIds = {}
and then using something similar to table.insert(usedIds, id) when the vehicle spawns.

You then need to add a check, to see if the id is already used, with something similar to:
if table.find(usedIds, id) then return print("ID already used!") end

If you need a script, let me know!
Otherwise, hope this helped!

this works, but sometimes there are too many ids to keep track of, instead try using :GenerateGUID, then will return a special code