Why is this popping up whenever i make a new attribute?

im trying to add another datastore but it just shows this error.

image

this is my script

local dataStoreService = game:GetService("DataStoreService")
local PlayerStats = dataStoreService:GetDataStore("StatSave")

game.Players.PlayerAdded:Connect(function(player)
	local playerstats = Instance.new("Folder")
	playerstats.Name = "playerstats"
	playerstats.Parent = player
	

	playerstats:SetAttribute("Strength", 1) -- done
	playerstats:SetAttribute("Protection", 1) -- done
	playerstats:SetAttribute("Dexterity", 1) -- done
	playerstats:SetAttribute("Sorcery", 1)
	playerstats:SetAttribute("Charisma", 1) -- done
	playerstats:SetAttribute("Intelligence", 1)
	playerstats:SetAttribute("Damage", 1) -- done
playerstats:SetAttribute("Stats", 200)
	



	local strengthdata, protectiondata, dexteritydata, sorcerydata, charismadata, intelligencedata, damagedata, statsdata
	local success, errormessage = pcall(function()

		strengthdata = PlayerStats:GetAsync(player.UserId.."-Strength")
		protectiondata = PlayerStats:GetAsync(player.UserId.."-Protection")
		dexteritydata = PlayerStats:GetAsync(player.UserId.."-Dexterity")
		sorcerydata = PlayerStats:GetAsync(player.UserId.."-Sorcery")
		charismadata = PlayerStats:GetAsync(player.UserId.."-Charisma")
		intelligencedata = PlayerStats:GetAsync(player.UserId.."-Intelligence")
		damagedata = PlayerStats:GetAsync(player.UserId.."-Damage")
		statsdata = PlayerStats:GetAsync(player.UserId.."-Stats")
	
	end)
	if success then
		playerstats:SetAttribute("Strength", strengthdata)
		playerstats:SetAttribute("Protection", protectiondata)
		playerstats:SetAttribute("Dexterity", dexteritydata)
		playerstats:SetAttribute("Sorcery", sorcerydata)
		playerstats:SetAttribute("Charisma", charismadata)
		playerstats:SetAttribute("Intelligence", intelligencedata)
		playerstats:SetAttribute("Damage", damagedata)
		playerstats:SetAttribute("Stats", statsdata)


	else
		print("Error.")
		warn(errormessage)
	end
end)




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

	local success, errormessage = pcall(function()
		PlayerStats:SetAsync(plr.UserId.."-Strength", plr.playerstats:GetAttribute("Strength"))
		PlayerStats:SetAsync(plr.UserId.."-Protection", plr.playerstats:GetAttribute("Protection"))
		PlayerStats:SetAsync(plr.UserId.."-Dexterity", plr.playerstats:GetAttribute("Dexterity"))
		PlayerStats:SetAsync(plr.UserId.."-Sorcery", plr.playerstats:GetAttribute("Sorcery"))
		PlayerStats:SetAsync(plr.UserId.."-Charisma", plr.playerstats:GetAttribute("Charisma"))
		PlayerStats:SetAsync(plr.UserId.."-Intelligence", plr.playerstats:GetAttribute("Intelligence"))
		PlayerStats:SetAsync(plr.UserId.."-Damage", plr.playerstats:GetAttribute("Damage"))
		PlayerStats:SetAsync(plr.UserId.."-Stats", plr.playerstats:GetAttributes("Stats"))
	end)

	if success then
		print("Saved PlayerData!")
	else
		print("Error with saving PlayerData.")
		warn(errormessage)
	end
end)

You can’t put dictionaries in an attribute as it is not supported.

If you don’t know what a dictionary is it is a type of table.

Most likely your PlayerStats:GetAsync must had return a dictionary, you can try printing it.

1 Like

yeah it printed but how do i fix it?

You just can’t use dictionaries, it’s not supported. So you would have to get the values out of the dictionary one by one, and store it in it’s own attribute.

1 Like

Also, I wouldn’t recommend saving the values in multiple different datastores, as this may reach the read and write limit, and you might have some data issues. I recommend using ProfileService as it makes it much easier, and I personally use it. Also it isn’t a service that can be accessed, it’s just what it’s called. Here’s the documentation if you really need it ProfileService

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.