Hello, I’m making a Trail shop and inventory system but it only saves one trail and doesn’t save the other trails. This is my first time using DataStore2 yet I know how to use it except for saving tables
I use DataStore2 for this
This is the code
function PlayerDataModule:TrailSave(LocalPlayer)
local OwnedTrails = {}
local TrailStore = DataStore2Module("Trails", LocalPlayer)
local GetTrailTable = TrailStore:GetTable(OwnedTrails)
for _, trl in pairs(LocalPlayer.Trails:GetChildren()) do
table.insert(GetTrailTable, trl.Name)
TrailStore:Save(GetTrailTable)
print("Saving...")
end
end
Loading the trails
local TrailStore = DataStore2Module("Trails", LocalPlayer)
local GetTrailTable = TrailStore:GetTable(TrailsOwned)
for _, trl in pairs(GetTrailTable) do
if TrailFolder:FindFirstChild(trl) then
print(trl)
local TrailObj = TrailFolder[trl]:Clone()
TrailObj.Parent = Trails
end
end