Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Can datastore store anything?

Asked by 8 years ago

I have created a script that saves players points and all but how do i make it save players stuff like hats and to their inventory, sorry i'm still learning Lua.

local DataStore = game:GetService("DataStoreService"):GetDataStore("Shop")

game.Players.PlayerRemoving:connect(function(player)

    local key = "player-"..player.userId

    --Save key: {points, coins}
    local valuesToSave = {player.leaderstats.Points.Value, player.leaderstats.Coins.Value}
    DataStore:SetAsync(key, valuesToSave)

end)


2 answers

Log in to vote
0
Answered by 8 years ago

Unfortunately, there is no way to save direct assets like there was with DataPersistance. However, what you can do is make a bool value for every asset you want and then save and load the value of the bool when they enter and save. You then can copy the asset that you want over to the player only if the bool of that asset is true when they enter.

Ad
Log in to vote
-1
Answered by 8 years ago

You can save everything there, I recommend using folders to save in your case.

Peasfactory

Answer this question