Hello, I have a system that saves 3 vars to a table when an item is released (child is added into a frame.)
Now the issue I am experiencing is that whenever I want to release a new item the previous item is overwritten by the new item, therefor causing it to not save/load when the player rejoins. What should I do? Thanks!
game.Players.PlayerAdded:Connect(function(plr)
wait(1)
local GuiData = game:GetService("DataStoreService"):GetDataStore("guiSaves"):GetAsync(plr.UserId.."-save")
local GuiData = game:GetService("DataStoreService"):GetDataStore("guiSaves"):GetAsync(plr.UserId.."-save")
if GuiData then
local Name = GuiData.Name
local ImageID = GuiData.Image
local Value = GuiData.Value
local clone = game.ReplicatedStorage.Scroll.Template:Clone()
clone.Price.Value = Name
clone.ItemName.Value = Value
clone.Name = Name
clone.Visible = true
clone.ItemPrice.Text = Name
clone.Picture.Image = ImageID
clone.Title.Text = Value
clone.Parent = game.ServerStorage
wait(0.3)
clone.Parent = game.ReplicatedStorage.Scroll
print("working....")
clone:Clone().Parent = plr.PlayerGui.CatalogGui.BackgroundGui.MainGui.Scroll
print("done")
else
game.DatastoreService:GetDatastore("guiSaves"):SetAsync(plr.UserId.."-save", {})
end
game.ReplicatedStorage.Scroll.ChildAdded:Connect(function(child)
if child:FindFirstChild("IsDropped") then
for i,v in pairs(game.ReplicatedStorage.Scroll:GetChildren()) do
if v:FindFirstChild("IsDropped") then
local save = {}
save.Name = child.Name
save.Value = child.ItemName.Value
save.Image = child.Picture.Image
print("saving")
game:GetService("DataStoreService"):GetDataStore("guiSaves"):SetAsync(plr.UserId.."-save", save)
print("saved")
end
end
end
end)
end)```