Table datastores not working?

Hello there I’m trying to make table datastores from @Alvin_blox but it
always errors

i’m getting this error 103:Dictionary is not allowed on data stores.

I have tried pcalling, trying it in different places,i have checked the devforum and nobody made a post about this

local datastoreservice = game:GetService("DataStoreService")

local datastore = datastoreservice:GetOrderedDataStore("Datastore")

game.Players.PlayerAdded:Connect(function(player)
	local piggyTokens = Instance.new("IntValue")
	piggyTokens.Name = "Tokens"
	piggyTokens.Value = 1000
	piggyTokens.Parent = player
	
	local trapInventory = Instance.new("Folder")
	trapInventory.Name = "TrapInventory"
	trapInventory.Parent = player

	local skinInventory = Instance.new("Folder")
	skinInventory.Name = "SkinInventory"
	skinInventory.Parent = player
	
	local equippedTrap = Instance.new("StringValue")
	equippedTrap.Name = "EquippedTrap"
	equippedTrap.Parent = player
	
	local equippedSkin = Instance.new("StringValue")
	equippedSkin.Name = "EquippedSkin"
	equippedSkin.Parent = player
	
	local InMenu = Instance.new("BoolValue")
	InMenu.Name = "InMenu"
	InMenu.Parent = player
	
	local data
	
	local success,errorMsg = pcall(function()
		data = datastore:GetAsync(player.UserId)
	end)
	
	if data ~= nil then
		if data.EquippedTrap then
			equippedTrap.Value = data.EquippedTrap
		end
		
		if data.EquippedSkin then
			equippedSkin.Value = data.EquippedSkin
		end
		
		if data.Tokens then 
			piggyTokens.Value = data.Tokens
		end
		
		if data.Skins then
			for i, v in pairs(data.Skins) do
				local val = Instance.new("StringValue")
				val.Name = v
				val.Parent = skinInventory
			end
		end
		
		if data.Traps then
			for i, v in pairs(data.Traps) do
				local val = Instance.new("StringValue")
				val.Name = v
				val.Parent = trapInventory
			end
		end
		
	end
	
	game.ReplicatedStorage.SendData:FireClient(player,data)
	
	player.CharacterAdded:Connect(function(char)
		char.Humanoid.Died:Connect(function()
			
			if char:FindFirstChild("HumanoidRootPart") then
				if player:FindFirstChild("Contestant") and game.Workspace:FindFirstChild("Map") then
					keymodule.DropTools(player, game.Workspace.Map, char.HumanoidRootPart.Position)
					print("Tools dropped")
				end
			end
			
			if player:FindFirstChild("Contestant") then
				player.Contestant:Destroy()	
			elseif player:FindFirstChild("Piggy") then
				player.Piggy:Destroy()
			end
			
		end)
	end)
end)

game:BindToClose(function()
	-- will run when the server is about to shutdown
	for i, player in pairs(game.Players:GetPlayers()) do
		local data = {}
		
		data.Tokens = player.Tokens.Value
		
		data.EquippedTrap = player.EquippedTrap.Value
		data.EquippedSkin = player.EquippedSkin.Value
		
		data.Skins = {}
		data.Traps = {}
		
		for i, v in pairs(player.SkinInventory:GetChildren()) do
			table.insert(data.Skins, v.Name)
		end
		
		for i, v in pairs(player.TrapInventory:GetChildren()) do
			table.insert(data.Traps, v.Name)
		end
		
		local success,errorMsg = pcall(function()
			datastore:SetAsync(player.UserId,data)
		end)
		
		if success then
			print("Success")
		end
		
		if errorMsg then
			print("Error found while trying to save data (are roblox datastore servers down?)"..errorMsg)
		end
	end
end)

local trapDebounce = false

game.Players.PlayerRemoving:Connect(function(player)
	
	local data = {}
	
	data.Tokens = player.Tokens.Value
	
	data.EquippedTrap = player.EquippedTrap.Value
	data.EquippedSkin = player.EquippedSkin.Value
	
	data.Skins = {}
	data.Traps = {}
	
	for i, v in pairs(player.SkinInventory:GetChildren()) do
		table.insert(data.Skins, v.Name)
	end
	
	for i, v in pairs(player.TrapInventory:GetChildren()) do
		table.insert(data.Traps, v.Name)
	end
	
	local success,errorMsg = pcall(function()
		datastore:SetAsync(player.UserId,data)
	end)
	
	if success then
		print("Success")
	end
	
	if errorMsg then
		print("Error found while trying to save data (are roblox datastore servers down?)"..errorMsg)
	end
end)

This is my first time getting an error in datastore tables, I’m not really that good at making datastores.

Try changing:

local datastore = datastoreservice:GetOrderedDataStore("Datastore")

To:

local datastore = datastoreservice:GlobalDataStore("Datastore")

This fellow ran into the same problem… typically ordered datastores are used for leaderboards, but not regular data.

Check this thread as well, that asked about your error:

1 Like

I get this now

GlobalDataStore is not a valid member of DataStoreService

i have this

local datastoreservice = game:GetService("DataStoreService")
	
local datastore = datastoreservice:GlobalDataStore("Datastore")

Yes, ordered data stores are used for leaderboards, so they don’t allow dictionaries, only normal tables (I believe). You have to do:

local datastore = DataStoreService:GetDataStore("Name")

You don’t do :GetGlobalDataStore() with a parameter, it’s by itself. So, if you want a custom data store, then you need to use :GetDataStore().

3 Likes

Ok, i’m watching Alvin_Blox’s video now to see what helps might need to be fixed.

1 Like

Okay. it’s also at episode 8 (30 chars)

Works well thank you so much (30 chars)

1 Like

@Steven_Rafft @TheCarbyneUniverse haha I just realized the error too… you beat me to the fix. :slight_smile:

1 Like

lol, how can i close my post since its solved (this probably sounds stupid to other ppl that have been a member for more than a week lol)

Its actually a good question. Glad you asked it.

1 Like