In the future make sure ALL your code is put into your code block format. The first 5 lines aren’t and the fact that the error lies there makes it harder to notice.
The issue is that your Players.PlayerRemoving event is nested in your Players.PlayerAdded event. Move the event outside of the PlayerAdded event and replace the function with this:
game.Players.PlayerRemoving:Connect(function(player)
local Value = player.NotesFolder.Notes.Value
TotalNotesSave:SetAsync(player.UserId , Value)
end)
This code isn’t sustainable in the long term in some cases because the player instance might disappear before the script can get their notes value. I’d suggest having another folder in ServerStorage where you get your values from when the player leaves.