Check if value in datastore already exists

I’m creating a group system where a player can create a group containing a unique tag and a unique id.

While the id cannot be changed, the tag should be changeable, however only if the new does not exist.
The key for the group datastore is the id.

Issue:
I do not know how to check if the tag already exist. using the tag as key would create endless problems.

My idea:
another datastore where I save the tag as key and id as value and check that. that’ll work for me however I’m wondering if there’s a cleaner solution.

Thanks.

The only other method I can think of (using DataStore:ListKeysAsync()) would be much slower and would require way more requests to Roblox’s servers than we need to consume, so I think your idea is the way to go. Remember to wrap requests to both datastores in pcalls to ensure nothing breaks between the two!

1 Like

thank you. small follow up, I found a way to save it with the tag as key :smiley:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.