So I got a banning script which uses DataStores, and it can handle saving and loading arrays perfectly fine.

game.ReplicatedStorage:WaitForChild('Bans').OnServerEvent:Connect(function(plr, reason)
	if plr.Name ~= 'hiimgoodpack' then
		warn(plr.Name..' tried to set a false ban.');
		game:GetService('DataStoreService'):GetDataStore('Bans'):SetAsync(plr.UserId, {tick() + 172800, 'Auto banned from system by trying to set a false ban.'});
		plr:Kick('You have been banned for trying to set a false ban. Your time remaining until you get unbanned is 2 days. If you think this is an error, please message me via ROBLOX.');
	else
		warn('hiimgoodpack kicked '..game.Players:GetPlayerByUserId(userid).Name..' for '..reason..' for '..releasetime / 60 ..' seconds.');
		game:GetService('DataStoreService'):GetDataStore('Bans'):SetAsync(userid, {tick() + releasetime, reason});
		game.Players:GetPlayerByUserId(userid):Kick('You have been banned for '..reason..'. Your time remaining until you get unbanned is '.. releasetime / 60 ..' minutes. If you think this is an error, please message me via ROBLOX.')
	end
end)

But, I made another script that saves datastores with this error. Arrays cannot be saved using data stores. or something along the lines of that. Here is basically what I did.

game.ReplicatedStorage:WaitForChild('ScriptData'):Connect(function(plr, use, stuff)
	if use == 'Save' then
		scripts:SetAsync(plr.UserId, stuff)
	end
end)

Localscript:

script.Parent.Parent.Save.MouseButton1Click:Connect(function()
	print('Saving scripts...')
	local scripts = {}
	
	for i, v in pairs(script.Parent:GetChildren()) do
		if v.ClassName ~= 'LocalScript' and v.ClassName ~= 'UIGridLayout' and v.Name ~= 'Ready' then
			table.insert(scripts, v)
		end
	end
	
	local data = {}
	
	for i, v in pairs(scripts) do
		print('Saving '..tostring(v.Name))
		if v:FindFirstChild('Code') then
			table.insert(data, {v.Name, v.Code.TextBox.Text})
		else
			table.insert(data, {v.Name, script.Parent.Parent.Parent.Code.TextBox.Text})
		end
	end
	
	remote:FireServer('Save', data)
end)

This is used with a local script firing the server script, and this is a script listening to the remote. Any ideas? I know I can use JSON, but I want to know how to save it as a table so I can easily debug problems with a datastore editor and using my plugin fifty million times here.

3 comments

0

If we don't know what "stuff" is, there is no way we can help you!

1

It's a table. That is why there is an "Arrays cannot be saved using data stores." error. That would not happen if IT WASNT AN ARRAY USE SUM COMMON SENSE OK?

0

We'd still like to see it though. Vector3 and Color3 values raise the same error when they're saved to datastores, btw. (I think?)