Attributes don't save

my attributes wont save it will print the right number but it does get past the checking when the player joins, so when it says if ------ and data[“Progress2”] then it won’t get past that

when the player joins

player.Values.CurrentQuest1:SetAttribute("Progress1", 0)
	player.Values.CurrentQuest2:SetAttribute("Progress2", 0)
	player.Values.CurrentQuest3:SetAttribute("Progress3", 0)
	
	for name, value in pairs(valuesTable) do
		if name == "CurrentQuest1" then
			if success and data and data["Progress1"] then
				player.Values.CurrentQuest1:SetAttribute("Progress1", data["Progress1"])
			end
		elseif name == "CurrentQuest2" then
			print("3")
			if success and data and data["Progress2"] then
				print(data["Progress2"])
				player.Values.CurrentQuest2:SetAttribute("Progress2", data["Progress2"])
			end
		elseif name == "CurrentQuest3" then
			if success and data and data["Progress3"] then
				player.Values.CurrentQuest3:SetAttribute("Progress3", data["Progress3"])
			end
		end
	end

when he leaves

function attributesToTable(valuesFolder)
	local tbl = {}

	for i, intValue in pairs(valuesFolder:GetChildren()) do
		if intValue.Name == "CurrentQuest1" then
			tbl["Progress1"] = intValue:GetAttribute("Progress1")
		elseif intValue.Name == "CurrentQuest2" then
			tbl["Progress2"] = intValue:GetAttribute("Progress2")
		elseif intValue.Name == "CurrentQuest3" then
			tbl["Progress3"] = intValue:GetAttribute("Progress3")
		end
	end

	return tbl
end

local dataToSave = dataToTable(leaderstatsToTable(leaderstatsFolder),valuesToTable(valuesFolder),attributesToTable(attributesFolder)

some off the leaderstats stuuf is in the script to but thats not the problem

1 Like

Can you print data and see if data.Progress2 even exists?

1 Like

it says nil when the player join

That means attributesToTable is failing. Does valuesFolder.CurrentQuest2 exist when the player leaves?

Attributes always work, just make sure its server to server client to client and you don’t have attribute missing strings

yes but I think the problem is when the script is trying to find the attribute because it does the same for the name as for the value

actully i’ve checked and it prints nil

Are you sure the attributes and values you’re accessing in the script are things the player has? Try printing intValue.Name in the for loop and see what happens.