Unity- Saving Floats to txt Files- Please Help :(

Hello,
i wrote this Code, but i also get a Error:
Assets/SourceSystem/KerboGames/ProgrammCode/Verwaltung/Speichern/SaveSystem.cs(53,20): error CS1502: The best overloaded method match for System.IO.File.WriteAllText(string, string)' has some invalid arguments Assets/SourceSystem/KerboGames/ProgrammCode/Verwaltung/Speichern/SaveSystem.cs(53,85): error CS1503: Argument #2’ cannot convert float' expression to type string’
Assets/SourceSystem/KerboGames/ProgrammCode/Verwaltung/Speichern/SaveSystem.cs(43,61): error CS1503: Argument #1' cannot convert string’ expression to type `float’

I want to Save the Players Current Position, i dont want to use player prefs.

The Code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;

public class SaveSystem : MonoBehaviour {
public GameObject Player;
public Transform Light;
public Transform Railroad;
public float Basi1;
public float Basi2;
public float Basi3;

//public GameObject SaveUI;




[HideInInspector]
public float Time;


void Start(){
	Basi1 = Player.transform.position.x;
	Basi2 = Player.transform.position.y;
	Basi3 = Player.transform.position.z;
}

void Update(){
	if (Input.GetKey("f5") ){
		Save();
	}
		
		if (Input.GetKey("f8")){
			LoadSave();
		}
		
	}


 public void LoadSave () {
	 
        Vector3 savedPosition = new Vector3 (System.IO.File.ReadAllText("Data1.sdpackage"), System.IO.File.ReadAllText("Data2.sdpackage"), System.IO.File.ReadAllText("Data3.sdpackage"));
        Player.transform.position = savedPosition;
		
		
        }
 public void Save() {
        
		 //SaveUI.gameObject.SetActive(true);
            Debug.Log("Saving...");
			
			 System.IO.File.WriteAllText("C:/KerboGames/SourceSystem/Saves/Data1.sdpackage", Basi1);
			 System.IO.File.WriteAllText("C:/KerboGames/SourceSystem/Saves/Data2.sdpackage", Basi2);
			 System.IO.File.WriteAllText("C:/KerboGames/SourceSystem/Saves/Data3.sdpackage", Basi3);
		
		
		
		//PlayerPrefs.SetInt("ZHP", vp_FPPlayerDamageHandler.hea) 
		
		Debug.Log("Saved Sucessfully");
		//SaveUI.gameObject.SetActive(false);
		
		
		
		
        
    }
}

Please Help me :slight_smile:

Thank you!

You can use .ToString() to convert it to string : Basi1.ToString()

You may also want to look at JsonUtility or xml serialisation.

Okay It works! Thank you :wink: