so im making an upgraded version of regular tycoon and i have to make a script that saves things player has bought. i was trying to do it multiplie ways like saving their parents as a string, but none worked. if the game wont have a saving script its gonna die so im kinda worried. heres my current script that tries to save their parent but it doesnt work:
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
v.Parent = ds2:GetAsync(plr.UserId)
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)
local success,err = pcall(function()
for i,v in pairs(purchasables) do
ds2:SetAsync(plr.UserId, v.Parent)
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
huh
what were you expecting?