So I’m trying to create values inside the player in a folder but I’m gonna have a Lot of them, so is there a way I could like put the names in a table and then they will still save to! like this!
local savingTable = {"Multiplier","Multiplier2","Multiplier3"}
1 Like
i think this can help you bro
local Players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("Example")
local Prefix = "Player: "
local function Save(player: Player)
local Key = Prefix.. tostring(player.UserId)
local Data = {}
local Folder = game.Players:FindFirstChild(player.Name):WaitForChild("UserData")
for i, Obj: BasePart in ipairs(Folder:GetChildren()) do
table.insert(Data, {
Obj.Name,
Obj.CanCollide
})
end
local Succes, Error
repeat
Succes, Error = pcall(function()
DataStore:UpdateAsync(Key, function()
return Data
end)
end)
task.wait()
until Succes
if not Succes then
warn("Failed to save data: ".. tostring(Error))
end
end
This…isn’t even remotely related to what the OP was asking (excluding all the errors).