Sorry, but it's simply not possible for browser-based applications to write any files at all. That's just not how browser-based applications work (thankfully - just imagine what bad actorspeople could do when they could write aany files they want to your local filesystem while you visit their website). When you need persistence in a Unity WebGL game, then there are basically two options.
- Use the
PlayerPrefsclass. On the webGL platform , it's implemented by the indexedDB api, which works similar to browser cookies, but allows to store a lot more data in a more efficient manner. - Create your own webservice API which allows game clients to store and retrieve savegames stored in a database you operate. You can't do that in Unity, but there are countless technologies available for doing that. Your game can then access that API with UnityWebRequest for uploading and downloading savegames.