I’m trying to use the DataStore2 module to save the player’s items in my tycoon but after I click “stop” in Studio I meet the error in the title.
At the moment I’m trying only the saving feature of the tycoon(saving of cash is commented). I am trying to save in a dictionary.
local DataStore2 = require(script.Parent.DataStore2)
DataStoreName = "ANameForThisPurpose"
DataStore2.Combine(DataStoreName, "Tycoon", "CashSave") --What is saved
game.Players.PlayerAdded:Connect(function(player)
print(player.Name)
end)
game:BindToClose(function()
-- triggers at shutdown
if game:GetService("RunService"):IsStudio() then
return
end
end)
function Purchase(tbl)
local userTycoon = DataStore2("Tycoon",script.Parent.Owner.Value):Get({})
print("ok5")
local cost = tbl[1]
local item = tbl[2]
local stats = tbl[3]
if not script.Parent.PurchasedObjects:FindFirstChild(item.Object.Value) then
print("ok6")
stats.Value = stats.Value - cost
--DataStore2("CashSave",script.Parent.Owner.Value):Set(stats.Value)
print("ok7")
end
Objects[item.Object.Value].Parent = script.Parent.PurchasedObjects
userTycoon[item.Object.Value] = true
DataStore2("Tycoon",script.Parent.Owner.Value):Set(userTycoon)
print("ok8")