so im making an upgraded version of a regular tycoon and im trying to add saving items. So as i know you cant save model directly through data store service so i tried to save its parent (which should work right) but for some reason it isnt.
I tried to do it with
for i,v in pairs() do
but it didnt work either. So heres the script, also i would REALLY appreciate if someone knows a shorter way to do it, instead of adding several new lines for each new item.
local datastore = game:GetService("DataStoreService")
local ds2 = datastore:GetDataStore("DS2")
local basicdropper = game.ServerStorage.PURCHASABLES.BasicDropper
game.Players.PlayerAdded:Connect(function(plr)
local success,err = pcall(function()
basicdropper.Parent = ds2:GetAsync(plr.UserId)
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()
ds2:SetAsync(plr.UserId, basicdropper.Parent)
end)
if success then
print("Your Items Have Been Saved.")
else
print("We Got An Error While Saving Your Items.")
warn(err)
end
end)

16 comments
do you think it is possible to make it shorter?
i mean is it possible to make it so i dont have to add multiple lines for each new item?
@TFlanigan you wont need to add a line for each item
huh? what do you mean?
how
@TFlanigan how would you use this in a script, cause you shouldent need to add a line for every item
?
Let me add an example to the answer
?
oh ok
wait what the hell i thought u cant save models
Wait wait wait, So what is itembin? Should it be purchased items or purchasables? or both at the same time?
idk if im doing something wrong but i get this: http://prntscr.com/qwl36j
what im doing is saving the name of the model and using it to find the model in the next session
ItemBin would be like your inventory
ooh