Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why am i not able to save arrays to a data store?

This is very bad scripting. I know. But why is the table like this:

table = {
	1,
	2,
	3
}

local DataStoreService = game:GetService("DataStoreService")
local DataStore1 = DataStoreService:GetDataStore("ADifferentName") -- Change this with a different name.
local DataStore2 = DataStoreService:GetDataStore("AnotherName")

game.Players.PlayerRemoving:Connect(function(Player)

	local playerID = Player.UserId
	local data = Player.leaderstats.Legit.Value
	local levels = {

	}
	for i, v in pairs(Player.lvls:GetChildren()) do
		table.insert(levels, tostring(v))
	end
	print(levels)

	local success, errormessage = pcall(function()
		DataStore1:SetAsync(playerID, data)
		DataStore2:SetAsync(playerID, levels)
	end)

	if success then
		print("data successfully saved!")
	else
		print("hmmmmm no bueno")
		warn(errormessage)    
	end
end)

1 answer

✓ Accepted answer

I think inside the Player Player > lvls > are a lot of objects that are called 1...2...3... and so on?

1 comment

0

nope

This discussion is preserved as it was. New answers, comments, and votes are closed.