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

How would I make a script that saves an Instance? [closed]

Asked by 7 years ago

This question already has an answer here:

Possible to save Instances in DataStore?

I've been making a Pokemon game and I need it to save. There is a part called StoragePart in my game and in there is 2 folders, the 1st one is called YourPokemon where the Pokemon the player owns are stored and the 2nd one is called PokemonYouCanGet where the Pokemon that the player doesn't own and when a player catches a Pokemon, it duplicates the caught Pokemon and sends it to the YourPokemon folder and I need it to save. I've tried this script but it's not working:

DS=game:GetService("DataStoreService"):GetDataStore("Instances")
saved = {}
local Pokemon = game.Workspace.StoragePart.YourPokemon:GetChildren()
table.insert(saved, {
Pokemon[1].Name,
Pokemon[1].Level,
Pokemon[1].XP,
Pokemon[1].Nature,
Pokemon[1].NeededXP,
Pokemon[1].Image,
})
DS:SetAsync("Instances",saved)

Marked as Duplicate by cabbler and TheHospitalDev

This question has been asked before, and already has an answer. If those answers do not fully address your question, then please ask a new question here.

Why was this question closed?