ok so dont even tell me about datastore2... its too complicated. so im making an upgraded version of a regular tycoon and im trying to add item saving. what im trying to do is when player leaves it puts all items he bought into a table, and when he joins find them by name and put them into workspace. heres the script. it doesnt work even tho im not getting any errors. will be back in 2 hours so not gonna answer right now.
local datastore = game:GetService("DataStoreService")
local ds2 = datastore:GetDataStore("DS2")
local purchasables = game.ServerStorage.PURCHASABLES:GetChildren()
game.Players.PlayerAdded:Connect(function(plr)
local success,err = pcall(function()
for i,v in pairs(purchasables) do
if v.Name == val then
v.Parent = game.Workspace.PURCHASED
end
end
end)
if success then
print("Your Items Have Been Loaded.")
else
print("Your Items Loading Has Failed.")
warn(err)
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
for i,v in pairs(game.Workspace.PURCHASED:GetChildren()) do
tab,val = {},v.Name
table.insert(tab,val)
end
local success,err = pcall(function()
for i,v in pairs(purchasables) do
ds2:SetAsync(plr.UserId,val)
end
end)
if success then
print("Your Items Have Been Saved.")
else
print("We Got An Error While Saving Your Items.")
warn(err)
end
end)

2 comments
so which line is the error
bruh i said im not getting any errors dude