I'm really interested in datastores, and for my game i need to save multiple things. Tables came to my mind.
It did not work.
"Does anyone out there know how to save multiple data in one script?"
HERES MY FAILED ATTEMPT TO SAVE MULTIPLE DATA;
the only difference here is on line 35 and 36 and on line 50 and 51.
01 | -- services -- |
02 |
03 | local DataStoreService = game:GetService( "DataStoreService" ) |
04 | local SaveGameData = DataStoreService:GetDataStore( "SaveGameData" ) |
05 |
06 | -- variables |
07 |
08 | local RemoteEvent = game.ReplicatedStorage.RemoteEvent |
09 |
10 | -- leaderstats |
11 |
12 | game.Players.PlayerAdded:Connect( function (player) |
13 |
14 | local leaderstats = Instance.new( "Folder" , player) |
15 | leaderstats.Name = "leaderstats" |
Hello. You need the name of the dictionary's value. For example, instead of writing SavedGames.Value = Data
you'd write SavedGames.Value = Data.Games
. Try this:
01 | -- services -- |
02 |
03 | local DataStoreService = game:GetService( "DataStoreService" ) |
04 | local SaveGameData = DataStoreService:GetDataStore( "SaveGameData" ) |
05 |
06 | -- variables |
07 |
08 | local RemoteEvent = game.ReplicatedStorage.RemoteEvent |
09 |
10 | -- leaderstats |
11 |
12 | game.Players.PlayerAdded:Connect( function (player) |
13 |
14 | local leaderstats = Instance.new( "Folder" , player) |
15 | leaderstats.Name = "leaderstats" |
Please upvote and accept this answer if it helps.