You’re still trying to save an instance.
What should I replace this with? Because i followed through with the
v.InAlbum,v.placeholder
instead of the
v,v.InAlbum,v.placeholder
you told me
After messing around, i finally got a script to work.
With instances too. :
local Players = game:GetService("Players")
local dataStoreService = game:GetService("DataStoreService")
local dataKey1 = dataStoreService:GetDataStore("PlaceholderSongs10") -- used: 1, 2, 3, 4, 5, 6, 7 , 8, 9
Players.PlayerAdded:Connect(function(player)
local boolsFolder = Instance.new("Folder", player)
boolsFolder.Name = "Bools"
local songsFolder = Instance.new("Folder", boolsFolder)
songsFolder.Name = "Songs"
local playerkey = "bools_"..player.UserId.."_store"
dataKey1:GetAsync(playerkey)
local data = dataKey1:GetAsync(playerkey)
--local data2 = dataKey:GetAsync(equippedPlayerKey)
print(data)
if data ~= nil then
for i, v in pairs(data) do
print(v[1], v[2], v[3])
--for i, c in pairs(v) do
--print(c[1], c[2], c[3])
local songData1 = Instance.new("StringValue", songsFolder)
songData1.Name = v[1]
local imgData = Instance.new("StringValue", songData1)
imgData.Name = v[2]
local inAlbumData = Instance.new("StringValue", songData1)
inAlbumData.Name = v[3]
--end
end
end
end)
Players.PlayerRemoving:Connect(function(player)
local songsTable = {}
for i, v in pairs(player.Bools.Songs:GetChildren()) do
table.insert(songsTable, {v.Name,v.ImgID.Name,v.InAlbum.Name})
print(songsTable)
end
local playerkey = "bools_"..player.UserId.."_store"
dataKey1:SetAsync(playerkey, songsTable)
end)
(the lines which are cleared were me messing around)
and here’s one if you also want to save values:
local Players = game:GetService("Players")
local dataStoreService = game:GetService("DataStoreService")
local dataKey1 = dataStoreService:GetDataStore("PlaceholderSongs10")-- used: 1, 2, 3, 4, 5, 6, 7 , 8, 9
local dataKey2 = dataStoreService:GetDataStore("SongValuesPlaceholder1")
Players.PlayerAdded:Connect(function(player)
local boolsFolder = Instance.new("Folder", player)
boolsFolder.Name = "Bools"
local songsFolder = Instance.new("Folder", boolsFolder)
songsFolder.Name = "Songs"
local playerkey = "bools_"..player.UserId.."_store"
dataKey1:GetAsync(playerkey)
dataKey2:GetAsync(playerkey)
local data = dataKey1:GetAsync(playerkey)
local data2 = dataKey2:GetAsync(playerkey)
print(data)
print(data2)
if data ~= nil then
for i, v in pairs(data) do
print(v[1], v[2], v[3])
local songData1 = Instance.new("StringValue", songsFolder)
songData1.Name = v[1]
local imgData = Instance.new("StringValue", songData1)
imgData.Name = v[2]
local inAlbumData = Instance.new("StringValue", songData1)
inAlbumData.Name = v[3]
end
end
if data2 ~= nil then
for i, v in pairs(data2) do
print("savedsongValues"..v[2], v[3], v[4])
for i, c in pairs(player.Bools.Songs:GetChildren()) do
if c.Name == v[1] then
c.Value = v[2]
c.ImgID.Value = v[3]
c.InAlbum.Value = v[4]
end
end
end
end
end)
Players.PlayerRemoving:Connect(function(player)
local songsTable = {}
local songsValuesTable = {}
for i, v in pairs(player.Bools.Songs:GetChildren()) do
table.insert(songsTable, {v.Name,v.ImgID.Name,v.InAlbum.Name})
print(songsTable)
end
for i, c in pairs(player.Bools.Songs:GetChildren()) do
table.insert(songsValuesTable, {c.Name,c.Value,c.ImgID.Value,c.InAlbum.Value})
print(songsValuesTable)
end
local playerkey = "bools_"..player.UserId.."_store"
dataKey1:SetAsync(playerkey, songsTable)
dataKey2:SetAsync(playerkey, songsValuesTable)
end)