How to make a code that once redeemed expires and cannot be used by anyone else
Could you elaborate more please?
I guess you need to use boolean values, messaging service and datastores.
This is correct, although messaging service is unneeded in this case since I believe :GetAsync() doesn’t need the server to be reset.
GetAsync() can be outdated sometimes by referencing cached memory local to the server instead of globally used memory, which is why updating values has its own method for dataStores.
I would just use a DataStore for this since MessagingService may ocassionally fail.
A code that only one user can use?
Just use a dictionary for your codes, eg:
Codes = {
["FREECASH100"] = {
--you could put a verification function here
UsableByIDs = {8094244}
}
}
And then you can just do a verification check
if table.find(Codes.FREECASH100, Player.UserId) then
--reward stuff i guess lol
end
Once the code is inputted, use SetAsync to say that the code has been redeemed. If you want it for all users, use MessagingService to send a message to all servers to say that the item has been awarded.
This cant be 100% implemented because of server cacheing, but this is the best that you can do