Key System Logic, How to do it?

I want to make a key system just like If you purchased some premium app like Adobe or any paid apps, however, I want it to be only accessible by the said player or the appropriate owner/holder.

I am thinking to do this like for example, I made a two key. “16AS9” and “420USD”

Now, If the key “420USD” was owned by 420SonsAndFather and “16AS9” was owned by NoLifer. I want 420SonsAndFather not use NoLifer’s key. I want the only key to be accessible by their own holder. For example, I give the key “NewUser” for someone that I only wanted that key for him to use and not any other accounts, the “NewUser” key will only be accessible to that player.

How do I make it?

1 Like

Could you give more context for why you’re trying to make this?

When you purchase any key from paid app, YOU can only use it right? Even If you share your key with others, others cannot use it. That’s what I’m trying to say.

Could you give more context for what you’re trying to make here?

I want to make a key system in a UI. It will be like put “KEY HERE” GUI. I want the system to verify If the key is appropriate to the appropriate owner/holder. Only the owner can use their key and even If share with others, it will not work.

There still isn’t enough context for me to fully understand what you’re trying to do (why do there need to be keys, how would they be generated, in what context)

That aside, I will assume that this key will be generated + used in the same Roblox experience. When a key is generated for a user, you could store this in a DataStore under that specific user. When they go to use a key, you check if it exists in their DataStore

The keys are not generated by the player. It is already decided. For example, I want to make table

local KeyHolder = {AmongUs69, LOL420}
local Key = {YOURKEYHERE, KEYHERELOL)

now I want it the script to function like

If the Key is YOURKEYHERE and the username who put this KEY is AmongUs69, then the script will work. Else, it will not.

Save the key in the player’s datastore and then check it matches when they try to use it.

if key == datastorekey then
--stuff

I am new in lua coding. How do I do that? Would you give example?

Do you have a datastore implemented?

I will soon. I am asking how to implement the Key System Logic. I am not that creative and new at coding so I wanna know how to do it. For example the code is like

If this key is used then check If it matches the corresponding owner, If not. it will not work

This is pointless because if no one else can use it even if they have the key than just owner wouldn’t ever even want a key.

The point of the key is that only the appropriate owner can use it. You know other owner who can share key to others, right? That’s what I am trying to prevent.

So only give the account that you want access, well access!

I guess you are misunderstanding something here. What I mean by owner is the appropriate individual who owned the key, not myself or the game creator.

No I understand but this is redundant because if one account and one account only could ever use the key in the first place than why even have a key?

The key system is to prevent troll, hackers from entering the game. It is a personal key, just like If you buy a Synapse X. You can only use the key and you cannot share it with others.

I am planning to make a multiple key to whitelist members.

Is the key single use and only able to be used in one game session (i.e when the player leaves the key is no longer valid)? Otherwise you need to implement a datastore first.

Alright then, how do you want to add/modify keys cause i can do this pretty ez