hello, I have this simple data store script and I was wondering if there is a better way to save 120+ Int Values here is the code for saving 1 Int Value
local players = game:GetService("Players")
local dataStore = game:GetService("DataStoreService")
local DataStore1 = dataStore:GetDataStore("DataStore1")
players.PlayerAdded:Connect(function(player)
local folder = player:WaitForChild("Colors")
local Tool1= Instance.new("IntValue")
Tool1.Name = "Tool1"
Tool1.Parent = folder
Tool1.Value = DataStore1:GetAsync(player.UserId) or 0
DataStore1:SetAsync(player.UserId, Tool1.Value)
Tool1.Changed:Connect(function()
DataStore1:SetAsync(player.UserId, Tool1.Value)
end)
end)
local function SterelizeInts(arr : {number})
local sterData = ""
for _,num in arr do
sterData ..= num.." "
end
returm sterData
end
local function DesterelizeInts(sterData : string)
return sterData:split(" ")
end
If the values must be a part of the tool, consider using Instance Attributes (roblox.com). They are a lot faster and more efficient than (for example) IntValues. Only use this if you need to store names etc. to each value.
Generally, it is much better to use a regular table. The problem is it will only be accessible within the script. A very easy way to share this table with other scripts could be to use JSON Format (roblox.com) and store it in a string attribute.