"Array is not allowed on DataStores"

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to make a game where it would save the player name and the code created from TeleportService:ReserveServer() and save it into a specific player when they press a button that will fire the event called “SendPrivateServerData” to the server. I want the player name and code to save into an array with the other codes and player names.
  2. What is the issue? Include screenshots / videos if possible!
    I looked into the console at the server section and there was a warning that said “Array is not allowed on DataStores” and the data wont save.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I tried to use HttpService:JSONEncode but then there was another warning saying “String won’t save in data store”.
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
    I am not very experienced with Data Store, I use DataStore2 more often
-- This is an example Lua code block
local DataStore = game:GetService("DataStoreService")
local ServersDataStore = DataStore:GetOrderedDataStore("PrivateServersStore")
local TS = game:GetService("TeleportService")
local HttpService = game:GetService("HttpService")

local servers = {}

game.ReplicatedStorage.SendPrivateServerData.OnServerEvent:Connect(function(plr)
	local code = TS:ReserveServer(game.PlaceId)
	if servers[plr.Name] == nil then
		print("newData")
		table.insert(servers,{plr.Name,code,"No_one"})
	end
	local Success, Error = pcall(function()
		return ServersDataStore:SetAsync((716569060).."PrivateServersStore", servers)
	end)
	if Error then
		warn(Error)
	end
	TS:TeleportToPrivateServer(game.PlaceId,code,{plr})
end)

SOLUTION:
Basically I realised that I am a big dummy and I wrote :GetOrderedDataStore() instead of :GetDataStore() and now it works

1 Like

In the array you want to store you have : the player name (allowed) , a string (allowed) and a Tuple (depending on what does it contain you will be able or not to store it)

I’m not familiar with TeleportService so if you could print the variable “code” in the output to see exactly the value.

(Sorry for my english xd)

sruff
this is a image of the stuff it says in the dev console

I also printed the code

Try to do this maybe it works :
table.insert(servers,{plr.Name,tostring(code),"No_one"})

I tried it but sadly still doesn’t work

I found out that the error is linked with this error message

I know the code I wrote might be bad cuz as I said, I am not good at working with normal Data store