It’s good but the time wont work, if I do for example /ban 100 test it would say banned 00 test and nothing else, no time. so as a result it doesn’t actually ban people, just kicks them
I actually got the same error too and it was coming from this line:
local duration = string.sub(message, string.find(message, numbers));
Probably because the number in string.find()
was nil.
Edit: When you tested it out, did you enter the length of the duration in your message or just the username itself?
Nice tutorial, congratulations.
Just a quick comment/suggestion for anybody (with at least some scripting understanding; you may skip if not) reading this:
According to the Data Stores official documentation page, the Scopes feature is now a legacy feature and its use is no longer recommended.
According to this Data Stores article’s section, The new recommendation is to follow a more explicit approach to scoping by (in general terms) concatenating the actual scope to the DataStore key. This new approach enhances the use of DataStore:ListKeysAsync()
's first parameter which handles this new approach (and surely more methods yet to be introduced). Besides the fact that you may use multiple scopes with this new approach.
For instance:
Example 1 (simple scoping)
Scope: slot
New scoping:
local slot = "1"
local playerDataStore = DataStoreService:GetDataStore("PlayerDataStore")
local slotDataStoreKey = string.format("%s/slot_%s", userId, slot) -- "userId/slot_1"
-- I use the '/' separator for convenience, nevertheless it may be any character
Legacy scoping:
local slot = "1"
local playerInventoryDataStore = DataStoreService:GetDataStore("PlayerDataStore", slot)
local slotDataStoreKey = tostring(userId) -- "userId"
At this point (in this example), it doesn’t seem terribly different. That’s because simple scoping is supported for both, but the concept multiple scoping is more complex for the legacy format (check out Example 2).
Example 2 (multiple scopes)
Scopes: slot
, gold
New scoping:
local playerDataStore = DataStoreService:GetDataStore("PlayerDataStore")
local slot = "1"
local goldDataStoreKey = string.format("%s/slot_%s/gold", userId, slot) -- "userId/slot_1/gold"
Legacy scoping:
Having more than 1 scope is practically impossible without making an extra call to DataStoreService:GetDataStore()
, which isn’t desirable in any case because there would be more as minimum 2 separate DataStore calls for the same DataStore, which, in the long run, will overcomplicate everything.
As you may have noticed, a multi-scoped key follows the same format as a simple-scoped key. The new approach’s format is universal for every scope quantity! (Unlike the legacy approach).
I’m not saying that the use of the legacy scoping is “wrong”, nevertheless, the use of the new approach is encouraged because new methods may not support legacy approaches. But it’s up to you! You may use whichever approach you feel more comfortable with.
Hope this helps! Happy coding.