The error 519: Scope name exceeds the 50 character limit.
The key for this is randomly generated by math.random(0, 10000).
The datastore has AllScopes enabled and the scope is just “” (a bypass to get all keys basically.)
I thought that maybe theres decimals in the math.random so i used math.floor, i was wrong
a part of the code (the only part needed as far as I know)
local options = Instance.new("DataStoreOptions")
options.AllScopes = true
local DSS = game:GetService("DataStoreService")
local NationDS = DSS:GetDataStore("Nations", "", options)
local success, errorMessage = pcall(function()
(the error printed is the variable errorMessage)
(The variable t is a JSON)
The error message is indicating that the scope name is exceeding the 50 character limit.
One possible solution is to shorten the scope name. You can try using a hash function to generate a shorter string from the nation key. For example, you could use the string.sub function to extract the first few characters of the hash result.
Another solution is to use a custom key for the datastore, instead of relying on the math.random function to generate a random key. For example, you could use the name of the nation as the key, or a combination of the name and some other unique identifier.
If you need to keep the randomly generated key, you could store the key-value pair in a different datastore with a shorter scope name.
The name of my Datastore is “NationDS”, 8 characters
The Key is just a few numbers
Not quite sure what exactly the scope is but the datastore one is just “”
The Data getting saved is around 41 characters