I'm making a banning/unbanning system and data editing system, but how could I make a player/userid data store edit? what kind of datastore would I need to use? an ordered datastore?
Just a normal datastore. However, the player will need to visit the place first in order for it to work. You also need to make sure that Enable Studio Access to API Services is ticked on the game's page.
local DataStore = game:GetService("DataStoreService"):GetDataStore("YourDataStore") local UserId = game.Players:GetUserIdFromNameAsync("NameOfUserWhosStatYouWantToChange") local key = ("P" .. UserId) -- Whatever your key is. for i,v in pairs(DataStore:GetAsync(key)) do print(DataStore:GetAsync(key)[i]) -- Gets all of their stats. end -- To know what all the values are, just look at where you're saving them, and look at the order. The first one to print is the first one you're saving. DataStore:SetAsync(key, true) -- Example, would set banned to true if your first value is the "Banned" value. -- You can also do maths on their stats. local First = (DataStore:GetAsync(key)[1]) DataStore:SetAsync(key, First + 10) -- Would add 10 to their value. Must be an IntValue.
For more information: https://developer.roblox.com/articles/Data-store
Quoting the article on Datastores (https://developer.roblox.com/articles/Data-store) :
local DataStoreService = game:GetService("DataStoreService") local experienceStore = DataStoreService:GetDataStore("PlayerExperience") local success, err = pcall(function() experienceStore:SetAsync("Player_1234", 50) end)
That script basically gets the DataStoreService, then gets the data store called "PlayerExperience"
You can set values such as :SetAsync(Player, Ban) where ban would be a bool value.
You can use GetAsync(Player) and it would return the Ban value.
local DataStoreService = game:GetService("DataStoreService") local Banlist = DataStoreService:GetDataStore("Banlist") function BanPlayer(Player) local success, err = pcall(function() Banlist:SetAsync(Player, true) end) --kick the player from the game end function UnbanPlayer(Player) local success, err = pcall(function() Banlist:SetAsync(Player, false) end) end function CheckBan(Player) local success, Banned = pcall(function() return Banlist:GetAsync(Player) end) if success then --if Banned then kick the player in here. end end
Basically, Ban and Unban functions basically go to the Player value within Banlist and set it to true or false. CheckBan would check if a player is banned or not.
The script I made here isn't the best but it's to give you the concept. You should always use the Player's userId and NOT the username, since usernames can be changed, but UserIDs never change. Basically, something like BanPlayer(userId)
I'm not the best at scripting but I hope i've helped you.
I suggest you visit this article I quoted at first.