You can’t save a Table but you can save other Data Types, such as Boolean, Number, Integer and String, etc
You can however convert a Table into a JSON string and Save it to Data Store, although this is done automaticallyso you don’t have to but be careful because it has limitations and special rules.
You can convert Array, and Dictionary with string keys
You can’t convert Array with gaps, Mixed - Table and Dictionary with non string keys
And no you cannot store other data types that I didn’t mentioned to DataStore, ie Instances, Vector3, CFrame, and Color3 but they can be converted to other data types as well.
local savebanns = game:GetService(“DataStoreService”)
local data = savebanns:GetDataStore(“Banns”)
local addata = savebanns:GetDataStore(“Admins”)
–// Custom function \–
local function Warn(WarnText)
warn(WarnText)
end
local function Warn(PrintText)
print(PrintText)
end
local function Banned(Player,Time)
game.Players[Player]:Kick(“You has ben banned, wait “…Time…” to get unbanned!”)
end
local function BannedKick(Player,Time)
game.Players[Player]:Kick(“You has ben banned, wait “…Time…” to get unbanned!”)
end
local function Kick(Player,AdminName)
game.Players[Player]:Kick(“You has ben kicked by “…AdminName…” if u want to raport he, text at me with his name and what he do”)
end
–// Sistem \–
game.Players.PlayerAdded:Connect(function(plr)
if not table.find(_G.Admins, plr.Name) and table.find(_G.Banned, plr.Name) then
BannedKick(plr, game.ReplicatedStorage.RecentTime.Value)
end
end)
while wait() do
data:SetAsync(“Banns”, _G.Banned)
end
while wait() do
addata:SetAsync(“Admins”, _G.Admins)
end
For some reason I could save a table, what are you talking about? The table’s content was consistent every time i loaded. I am confused about why you think that you can’t save a table.
It can’t be saved directly as a Table but Roblox automatically converts it into a JSON string for you, so you don’t have to do it yourself, henceforth removing complexity for newbies while using DataStoreService.
(anything sent to Datastore will be converted to a JSON string, anything retrieved from DataStore will be converted back into it’s original form through the usage of JSONEncode and JSONDecode)
Yeah, I’m pretty sure that is normal, I’m not sure what @RuizuKun_Dev is talking about.
Every game I have made in the past 2 years has saved its contents in a table. I did later convert to JSON due to the fact that it uses less space, but I used regular tables for a long time before that.
You misinterpreted what he was saying even after he explained it again in pretty clear wording. He is saying technically a table is not stored, a string is stored with JSON. The actual table and its binary representation are not stored. I believe HttpService:JSONEncode/Decode are called internally or at least the same libraries behind them are used on the server. He is not saying “you have to convert it to JSON” he is saying “it is always converted to json.”
For users looking for this information who may be storing more data than a few strings and need to keep things low on size, I would actually really recommend storing tables in a custom data format instead of JSON. JSON can be rather clunky in size due to its syntax/readability which can increase the stored size of the data.
DataStore keys are like table keys. They define a certain string for which you later perform lookups under. Think of DataStores like a very big table (well, they actually are) and the methods you use (Set/GetAsync) are used to read from or write to that big table.
An article you may be interested in: attribute-value pair. This describes the concept behind key-value pairs we see for tables.