basically what i want is I want there to be 2 data thingies, 1 for saving ichor, money and your name, and this other one for saving things in a folder. how do I achieve this? here’s my script: `–//Datastore
local DataStoreService = game:GetService(“DataStoreService”) --Gets the DataStoreService
local dataStore = DataStoreService:GetDataStore(“Test”) --Gives the Datastore a name
–//Function
local function saveData(player) --Create out own function for saving data
local tableToSave = { --Creates a table for our values
player.PlaceName.Value;
player.Currency.Money.Value;
player.Currency.Ichor.Value
} --You can continue the list in the same order by adding "player.leaderstats.IntValueName.Value;"
local success, errorMessage = pcall(dataStore.SetAsync, dataStore, player.UserId, tableToSave) --Checks if datastore succeededlocal success2, errorMessage = pcall(dataStore.SetAsync, dataStore, player.UserId, toons) --Checks if datastore succeeded
if success then --If datastore success then
print("Data has been saved!") --Prints success
else --If datastore fails then
print("Data has not been saved!") --Prints failure
end
end
–//leaderstats
game.Players.PlayerAdded:Connect(function(player) --When a player joins the game
player.CharacterAdded:Wait() --Wait for the player to load
local leaderstats = Instance.new(“Folder”) --Creates a new folder for the player
leaderstats.Name = “Currency” --Sets Folder name to “leaderstats” --MAKE SURE YOU DON’T CHANGE THIS
leaderstats.Parent = player --Puts the Folder under the player
local name = Instance.new("StringValue")
name.Name = "PlaceName"
name.Parent = player
name.Value = "eeeeeeeeeeeee"
local coins = Instance.new("NumberValue")
coins.Name = "Money"
coins.Parent = leaderstats
coins.Value = 25
local ichor = Instance.new("NumberValue")
ichor.Name = "Ichor"
ichor.Parent = leaderstats
ichor.Value = 0
local data = nil --Data is empty
local data2 = nil --Data is empty
local success, errorMessage = pcall(function()
data = dataStore:GetAsync(player.UserId) --Finds the player's UserId and data
end)
if success and data then --If UserId and Data found then
name.Value = data[1] --Sets points to the first set of data
coins.Value = data[2]
ichor.Value = data[3]
else --If UserId or Data not found then
print("The Player has no Data!") --Player has no data
warn(errorMessage)
end
end)
game.Players.PlayerRemoving:Connect(function(player) --When player is leaving the game
saveData(player) --Save the player’s data
end)
game:BindToClose(function() --When the game’s servers are shutting down
for _, player in ipairs(game.Players:GetPlayers()) do --loop through all the players in the server
task.spawn(saveData, player) --save all the player’s data
end
end)` thanks!