Data not saving correctly


	local New = Instance.new("Folder", Player)
	New.Name = "PlayerRank"
	local Old = Instance.new("IntValue", New)
	Old.Name = "RankPoints"
	local Rank = Instance.new("StringValue", New)
	Rank.Name = "RankName"
	local MaxRankPoints = Instance.new("IntValue", New)
	MaxRankPoints.Name = "MaxRankPoints"
	local success,data = pcall(function()
		return Data:GetAsync(Player.UserId)
	end)

	if data then
		print("Data :P")
		Rank.Value = data[1]
		Old.Value = data[2]
		MaxRankPoints.Value = data[3]
	elseif not data then
		print("No Data")
			MaxRankPoints.Value = 100
	Rank.Value = "Cadet"
	Old.Value = 0
	end
end)

Players.PlayerRemoving:Connect(function(Player)
	local WillReturn = {}
	for i,v in ipairs(Player["PlayerRank"]:GetChildren()) do
			if v.Name == "RankName" then
			table.insert(WillReturn, 1, v.Value)
		end
		if v.Name == "RankPoints" then
			table.insert(WillReturn,2, v.Value)
		end
		if v.Name == "MaxRankPoints" then
			table.insert(WillReturn,3, v.Value)
		end
	end
	Data:SetAsync(Player.UserId, WillReturn)
	print("SHOULD SAVE OMG")
end)

Look like it’s not saving correctly, I don’t know why, it should save, but it’s printing “No Data”

Can you describe the issue? You made a very brief post, literally just showcasing the code. How would we know what your issue is if we have no context behind it?

If you’re only testing this on a one player server, include a game:BindToClose() function to accurately test it. (You should have one anyways)

EDIT: Also make sure Studio has access to API calls. I’ve seen plenty forget about that little button.

It’s just not saving the value, might be because i’m on studio?

Being on studio has nothing to do with this. It would be telling you there is an error, as long as you have API services enabled it should be able to save on Studio.

It’s on, but it’s not saving, and if I test on game I think it works, let me see…

Yes, it’s saving on game, but studio no